home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earcd / grafica / flashmandel / sources / flashmandel.c < prev    next >
C/C++ Source or Header  |  1998-02-02  |  129KB  |  3,896 lines

  1. /*******************************************************************************
  2. **
  3. **  Coded by Dino Papararo              01-Feb-1998
  4. **
  5. *******************************************************************************/
  6.  
  7. #define __USE_SYSBASE
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <proto/exec.h>
  13. #include <proto/dos.h>
  14. #include <proto/intuition.h>
  15. #include <proto/diskfont.h>
  16. #include <proto/graphics.h>
  17. #include <proto/gadtools.h>
  18. #include <proto/utility.h>
  19. #include <proto/iffparse.h>
  20. #include <proto/icon.h>
  21. #include <proto/asl.h>
  22. #include <exec/execbase.h>
  23. #include <exec/memory.h>
  24. #include <intuition/intuition.h>
  25. #include <intuition/gadgetclass.h>
  26. #include <graphics/gfxbase.h>
  27. #include <graphics/videocontrol.h>
  28. #include <graphics/scale.h>
  29. #include <iffp/ilbmapp.h>
  30. #include <devices/prtbase.h>
  31. #include <devices/printer.h>
  32.  
  33. #define __USE_FPU
  34.  
  35. #ifdef __USE_FPU
  36. #include <m68881.h>
  37. #else
  38. #include <mieeedoub.h>
  39. #endif
  40.  
  41. #define VERSION  "FlashMandel 0.870 "
  42. #define AUTHOR   "Dino Papararo"
  43. #define DATE     __AMIGADATE__
  44. #define COPYRIGHT "©1997"
  45. #define ADDRESS  "          Via Manzoni 184\n\n          80123    Napoli\n\n              Italia\n\n"
  46. #define EMAIL    "     E-Mail:  DinoP@IName.Com"
  47.  
  48. #define INIT_DEF_RMIN      -2.2
  49. #define INIT_DEF_RMAX      +0.8
  50. #define INIT_DEF_IMIN      -1.125
  51. #define INIT_DEF_IMAX      +1.125
  52. #define INIT_DEF_RMINSTR   "-2.2"
  53. #define INIT_DEF_RMAXSTR   "+0.8"
  54. #define INIT_DEF_IMINSTR   "-1.125"
  55. #define INIT_DEF_IMAXSTR   "+1.125"
  56.  
  57. #define DEF_WIDTH      640
  58. #define DEF_HEIGHT     480
  59. #define DEF_PLANES     4
  60. #define DEF_MONITOR    0x00008004
  61. #define DEF_MONITORSTR "0x00008004"
  62.  
  63. #define MIN_WIDTH  640
  64. #define MIN_HEIGHT 480
  65. #define MIN_DEPTH  3
  66. #define MAX_DEPTH  8
  67.  
  68. #define RAW_ESC      0x045
  69. #define VAN_ESC      0x01B
  70. #define TAB          0x042
  71.  
  72. #define FIXED_POINT      (28L)                /* Bit di Precisione */
  73. #define MAX_POT          (1L << FIXED_POINT)  /*   2^FIXED_POINT   */
  74.  
  75. #define MINLIMIT 2
  76.  
  77. #define BLACK      (0)
  78. #define LIGHT_GREY (2)
  79. #define WHITE      (1)
  80. #define DARK_GREY  (3)
  81.  
  82. #define POINTS       4
  83. #define PAIRS        5
  84.  
  85. #define MYSECS       (50L << 1L)
  86.  
  87. #define SHIFTRIGHT   FALSE
  88. #define SHIFTLEFT    TRUE
  89.  
  90. #define INITIALZOOM  14
  91.  
  92. #define ZPW          15
  93. #define ZPH          15
  94. #define ZPXO         -8
  95. #define ZPYO         -7
  96.  
  97. #define ZZZPW        16
  98. #define ZZZPH        16
  99. #define ZZZPXO       0
  100. #define ZZZPYO       0
  101.  
  102. #define MAXCHARS     85
  103.  
  104. #define ACCEPT       (1)
  105. #define RATIO        (2)
  106. #define RESET        (3)
  107. #define CANCEL       (4)
  108. #define KEEP         (5)
  109.  
  110. #define PICTURE_MODE (1)
  111. #define PALETTE_MODE (0)
  112.  
  113. #define WMASK  0x1
  114. #define FMASK  0x2
  115. #define VMASK  0x4
  116. #define SMASK  0x8
  117. #define BMASK  0x10
  118. #define ZMASK  0x20
  119. #define TMASK  0x40
  120.  
  121. #define SPREAD_BIT (1L << 16)
  122. #define INTEGER_BIT (1L << 17)
  123. #define TITLE_BIT (1L << 18)
  124.  
  125. #define LOADPICTURE_MSG 0x1
  126. #define SAVEPICTURE_MSG 0x2
  127. #define DUMP_MSG        0x4
  128. #define REDRAW_MSG      0x8
  129. #define UNDO_MSG        0x10
  130. #define DRAW_MSG        0x20
  131. #define PREVIEW_MSG     0x40
  132. #define NEWDISPLAY_MSG  0x80
  133. #define STOP_MSG        0x100
  134. #define EXIT_MSG        0x200
  135. #define COORDS_MSG      0x400
  136. #define ITER_MSG        0x800
  137. #define ABOUT_MSG       0x1000
  138. #define TITLE_MSG       0x2000
  139. #define TIME_MSG        0x4000
  140. #define PALETTE_MSG     0x8000
  141. #define CYCLERIGHT_MSG  0x10000
  142. #define CYCLELEFT_MSG   0x20000
  143. #define DELAY_MSG       0x40000
  144. #define COLOR_MSG       0x80000
  145. #define LOADPALETTE_MSG 0x100000
  146. #define SAVEPALETTE_MSG 0x200000
  147. #define FONTREQ_MSG     0x400000
  148.  
  149. #define IDCMP_STANDARD  IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE|IDCMP_MENUPICK
  150.  
  151. #define WFLG_STANDARD WFLG_ACTIVATE|WFLG_BACKDROP|WFLG_NOCAREREFRESH|WFLG_SMART_REFRESH|WFLG_BORDERLESS|WFLG_REPORTMOUSE|WFLG_NEWLOOKMENUS
  152.  
  153. #define TEXT_ALERT_POS  "\x00\x90\x10 FlashMandel message: "
  154.  
  155. #define MODE_ID_MASK (LACE|HIRES|HAM|EXTRA_HALFBRITE)
  156.  
  157. #define ID_MAND MAKE_ID('M','A','N','D')
  158.  
  159. struct MandelChunk { WORD LeftEdge,TopEdge,Width,Height;
  160.                      long double RMin,RMax,IMin,IMax;
  161.                      long double RConst,IConst;
  162.                      ULONG Iterations;
  163.                      ULONG Special;
  164.                    };
  165.  
  166. IMPORT struct ExecBase *SysBase;
  167.  
  168. TEXT VERSION_STRING [] = "\0$VER: " VERSION DATE "\r\n by " AUTHOR;
  169.  
  170. TEXT MYFILE [80],MYDIR [220],MYPATH [300],BAR_STRING [80];
  171.  
  172. BOOL SPREAD = TRUE;
  173.  
  174. WORD ZOOMLINE [PAIRS << 1] , PRIORITY = 0 , MAX_ITERATIONS = 319;
  175.  
  176. UWORD MAX_ITERATIONS_PLUS_ONE;
  177.  
  178. LONG __oslibversion = 39L;
  179.  
  180. ULONG RETURNVALUE = NULL,MASK = TMASK;
  181.  
  182. ULONG ELAPSEDTIME = NULL,DELAY = 5L,COLOR_PENS;
  183.  
  184. long double RMIN=INIT_DEF_RMIN,RMAX=INIT_DEF_RMAX,IMIN=INIT_DEF_IMIN,IMAX=INIT_DEF_IMAX;
  185.  
  186. long double DEF_RMIN,DEF_RMAX,DEF_IMIN,DEF_IMAX,URMIN,URMAX,UIMIN,UIMAX;
  187.  
  188. long double FACTOR=0.0,INCREMREAL=0.0,INCREMIMAG=0.0,CRE=0.0,CIM=0.0;
  189.  
  190. ULONG *PALETTE;
  191.  
  192. WORD (*FUNCTION) (WORD,long double,long double);
  193.  
  194. VOID (*V_LINE) (struct RastPort *,const LONG,const LONG,const LONG);
  195.  
  196. VOID (*H_LINE) (struct RastPort *,const LONG,const LONG,const LONG);
  197.  
  198. CPTR *VINFO = NULL;
  199.  
  200. UBYTE *OpenDisplayError       = TEXT_ALERT_POS "I need at least 8 colors, sorry." "\x00";
  201. UBYTE *FontError              = TEXT_ALERT_POS "Font failed" "\x00";
  202. UBYTE *NoMonitor              = TEXT_ALERT_POS "No monitor" "\x00";
  203. UBYTE *NoChips                = TEXT_ALERT_POS "No chips" "\x00";
  204. UBYTE *NoMem                  = TEXT_ALERT_POS "No mem" "\x00";
  205. UBYTE *NoChipMem              = TEXT_ALERT_POS "No chipmem" "\x00";
  206. UBYTE *PubNotUnique           = TEXT_ALERT_POS "Pub not unique" "\x00";
  207. UBYTE *UnknownMode            = TEXT_ALERT_POS "Unknown mode" "\x00";
  208. UBYTE *ScreenTooDeep          = TEXT_ALERT_POS "Screen too deep" "\x00";
  209. UBYTE *AttachScreen           = TEXT_ALERT_POS "Attach screen failed" "\x00";
  210. UBYTE *ModeNotAvailableError  = TEXT_ALERT_POS "Mode not available" "\x00";
  211. UBYTE *UnknownScrError        = TEXT_ALERT_POS "Unknown screen error" "\x00";
  212. UBYTE *VisualInfoError        = TEXT_ALERT_POS "Visualinfo failed" "\x00";
  213. UBYTE *WindowError            = TEXT_ALERT_POS "Openwindow failed" "\x00";
  214. UBYTE *MenuError              = TEXT_ALERT_POS "Menu failed" "\x00";
  215. UBYTE *GadgetError            = TEXT_ALERT_POS "Gadget error" "\x00";
  216. UBYTE *WindowGadgetError      = TEXT_ALERT_POS "Window gadget error" "\x00";
  217. UBYTE *PreviewWindowError     = TEXT_ALERT_POS "Preview window failed" "\x00";
  218. UBYTE *CreateDisplayError     = TEXT_ALERT_POS "Createdisplay error" "\x00";
  219. UBYTE *DimensionInfoError     = TEXT_ALERT_POS "Dimensioninfo error" "\x00";
  220. UBYTE *DisplayInfoError       = TEXT_ALERT_POS "Displayinfo error" "\x00";
  221. UBYTE *PaletteRequesterError  = TEXT_ALERT_POS "Palette requester error" "\x00";
  222. UBYTE *MakeDisplayError       = TEXT_ALERT_POS "Display error" "\x00";
  223. UBYTE *QueryMandPicError      = TEXT_ALERT_POS "Not a FlashMandel picture !" "\x00";
  224. UBYTE *LoadMandPicError       = TEXT_ALERT_POS "Load picture error" "\x00";
  225. UBYTE *SaveMandPicError       = TEXT_ALERT_POS "Save picture error" "\x00";
  226.  
  227. VOID   PutPointer    (struct Window *,UWORD *,WORD,WORD,WORD,WORD,UBYTE);
  228. VOID   ClipIt        (WORD,WORD,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,struct Rectangle *,BOOL);
  229. ULONG  ModeFallBack  (ULONG,WORD,WORD,WORD);
  230. LONG   About         (struct Window *);
  231. LONG   Choice        (struct Window *,TEXT *,TEXT *);
  232. LONG   CheckGFX      (VOID);
  233. BOOL   CheckEHB      (ULONG);
  234. UBYTE  GetMaxPlanes  (ULONG);
  235. ULONG  CheckFPU      (UWORD);
  236. VOID   AdjustRatio   (long double *,long double *,long double *,long double *,WORD,WORD,BOOL);
  237. WORD   Integer       (WORD,long double,long double);
  238. WORD   Real          (WORD,long double,long double);
  239. VOID   ShowTime      (struct Window *,TEXT *,ULONG);
  240. ULONG  IntegerGad    (struct Window *,TEXT *,TEXT *,TEXT *,ULONG);
  241. VOID   CloseDisplay  (struct ILBMInfo *,CPTR *);
  242. LONG   MakeDisplay   (struct ILBMInfo *);
  243. VOID   VLine_R_EHB   (struct RastPort *,const LONG,const LONG,const LONG);
  244. VOID   HLine_R_EHB   (struct RastPort *,const LONG,const LONG,const LONG);
  245. VOID   VLine_S_EHB   (struct RastPort *,const LONG,const LONG,const LONG);
  246. VOID   HLine_S_EHB   (struct RastPort *,const LONG,const LONG,const LONG);
  247. VOID   VLine_R       (struct RastPort *,const LONG,const LONG,const LONG);
  248. VOID   HLine_R       (struct RastPort *,const LONG,const LONG,const LONG);
  249. VOID   VLine_S       (struct RastPort *,const LONG,const LONG,const LONG);
  250. VOID   HLine_S       (struct RastPort *,const LONG,const LONG,const LONG);
  251. BOOL   CheckBox      (struct RastPort *,const LONG,const LONG,const LONG,const LONG);
  252. BOOL   Rectangle     (struct Window *,const LONG,const LONG,const LONG,const LONG);
  253. BOOL   NewCoords     (struct Window *,const LONG,const LONG,const LONG,const LONG);
  254. BOOL   DrawFrame     (struct Window *,WORD,WORD,WORD,WORD);
  255. ULONG  DrawFractal   (struct Window *,const LONG,const LONG,const LONG,const LONG);
  256. BOOL   Preview       (struct Window *,const LONG,const LONG);
  257. BOOL   ShowCoords    (struct Window *);
  258. VOID   RestoreCoords (VOID);
  259. VOID   SaveCoords    (VOID);
  260. BOOL   FileRequest   (struct Window *,TEXT *,BOOL,BOOL);
  261. BOOL   FontRequest   (struct Window *);
  262. BOOL   SMRequest     (struct ILBMInfo *);
  263. VOID   SetMenuStart  (struct Window *);
  264. VOID   SetMenuStop   (struct Window *);
  265. ULONG  ProcessMenu   (struct Window *,UWORD);
  266. VOID   ProcessMouse  (struct Window *,WORD,WORD);
  267. ULONG  HandleEvents  (struct ILBMInfo *);
  268. LONG   WinDump       (struct Window *);
  269. ULONG  Fail          (UBYTE *,ULONG);
  270. BOOL   PasteWin      (struct BitMap *,struct Window *,WORD,WORD);
  271. LONG   main          (ULONG,UBYTE **);
  272.  
  273. struct Screen *OpenIdScreen (struct ILBMInfo *,WORD,WORD,WORD,ULONG);
  274. struct Window *OpenDisplay  (struct ILBMInfo *,WORD,WORD,WORD,ULONG);
  275. struct BitMap *CopyBitMap   (struct Window *,WORD,WORD,WORD,WORD);
  276.  
  277. struct Border       MYBORDER          = {0,0,0,0,COMPLEMENT,PAIRS,ZOOMLINE,0};
  278.  
  279. struct TextAttr     MYFONTSTRUCT      = {"topaz.font",8,FS_NORMAL,FPF_ROMFONT};
  280.  
  281. struct NewGadget    TEXTGAD           = {0,0,0,0,0,&MYFONTSTRUCT,0,0,0,0};
  282.  
  283. struct NewGadget    BUTTONGAD         = {0,0,0,0,0,&MYFONTSTRUCT,0,0,0,0};
  284.  
  285. struct NewGadget    CHECKBOXGAD       = {0,0,0,0,0,&MYFONTSTRUCT,0,0,0,0};
  286.  
  287. struct BitScaleArgs BSA               = {0,0,0,0,0,0,0,0,0,0,0,0,NULL,NULL,NULL,0,0,NULL,NULL};
  288.  
  289. struct Chunk        COPYRIGHT_CHUNK   = {NULL,ID_ILBM,ID_Copyright,IFFSIZE_UNKNOWN,"\n\n" VERSION COPYRIGHT " by " AUTHOR "\n\n"};
  290.  
  291. struct Chunk        SPECIAL_CHUNK     = {NULL,ID_ILBM,ID_MAND,sizeof (struct MandelChunk),NULL};
  292.  
  293. UWORD PENS [] = {BLACK,DARK_GREY,WHITE,WHITE,DARK_GREY,LIGHT_GREY,DARK_GREY,LIGHT_GREY,DARK_GREY,WHITE,LIGHT_GREY,DARK_GREY,(UWORD) ~0};
  294.  
  295. /*
  296.  
  297. 01    0 DETAILPEN             SFONDO
  298. 02    1 BLOCKPEN              TESTO
  299. 03    1 TEXTPEN               TESTO EVIDENZIATO
  300. 04    2 SHINEPEN              BORDI CHIARI
  301. 05    1 SHADOWPEN             BORDI SCURI
  302. 06    3 FILLPEN               BARRA TITOLO FINESTRE ATTIVE
  303. 07    1 FILLTEXTPEN           TITOLO FINESTRE ATTIVE
  304. 08    0 BACKGROUNDPEN
  305. 09    2 HIGHLIGHTTEXTPEN
  306.  
  307. 10    1 BARDETAILPEN          TESTO NEI MENU
  308. 11    2 BARBLOCKPEN           SFONDO NEI MENU
  309. 12    1 BARTRIMPEN
  310.  
  311. */
  312.  
  313. ULONG COLORS_32_ECS [] = {32L << 16L,
  314.                           0x00000000,0x00000000,0x00000000,
  315.                           0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
  316.                           0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,
  317.                           0x66666666,0x66666666,0x66666666,
  318.                           0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
  319.                           0xBBBBBBBB,0xBBBBBBBB,0xBBBBBBBB,
  320.                           0x77777777,0x77777777,0x77777777,
  321.                           0x33333333,0x33333333,0x33333333,
  322.                           0x33333333,0x33333333,0x00000000,
  323.                           0x77777777,0x77777777,0x00000000,
  324.                           0xBBBBBBBB,0xBBBBBBBB,0x00000000,
  325.                           0xFFFFFFFF,0xFFFFFFFF,0x00000000,
  326.                           0x00000000,0xFFFFFFFF,0x00000000,
  327.                           0x00000000,0xBBBBBBBB,0x00000000,
  328.                           0x00000000,0x77777777,0x00000000,
  329.                           0x00000000,0x33333333,0x00000000,
  330.                           0x33333333,0x00000000,0x33333333,
  331.                           0x77777777,0x00000000,0x77777777,
  332.                           0xBBBBBBBB,0x00000000,0xBBBBBBBB,
  333.                           0xFFFFFFFF,0x00000000,0xFFFFFFFF,
  334.                           0xFFFFFFFF,0x00000000,0x00000000,
  335.                           0xBBBBBBBB,0x00000000,0x00000000,
  336.                           0x77777777,0x00000000,0x00000000,
  337.                           0x33333333,0x00000000,0x00000000,
  338.                           0x00000000,0x33333333,0x33333333,
  339.                           0x00000000,0x77777777,0x77777777,
  340.                           0x00000000,0xBBBBBBBB,0xBBBBBBBB,
  341.                           0x00000000,0xFFFFFFFF,0xFFFFFFFF,
  342.                           0x00000000,0x00000000,0xFFFFFFFF,
  343.                           0x00000000,0x00000000,0xBBBBBBBB,
  344.                           0x00000000,0x00000000,0x77777777,
  345.                           0x00000000,0x00000000,0x33333333,
  346.                           NULL};
  347.  
  348. ULONG COLORS_32_AGA []  =  {256L << 16L,
  349.                             0x00000000,0x00000000,0x00000000, 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF, 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA, 0x66666666,0x66666666,0x66666666,
  350.                             0x9f9f9f9f,0x9f9f9f9f,0x9f9f9f9f, 0xafafafaf,0xafafafaf,0xafafafaf, 0xbfbfbfbf,0xbfbfbfbf,0xbfbfbfbf, 0xcfcfcfcf,0xcfcfcfcf,0xcfcfcfcf,
  351.                             0xdfdfdfdf,0xdfdfdfdf,0xdfdfdfdf, 0xefefefef,0xefefefef,0xefefefef, 0xdfdfdfdf,0xefefefef,0xffffffff, 0xcfcfcfcf,0xdfdfdfdf,0xefefefef,
  352.                             0xbfbfbfbf,0xcfcfcfcf,0xdfdfdfdf, 0xafafafaf,0xbfbfbfbf,0xcfcfcfcf, 0x9f9f9f9f,0xafafafaf,0xbfbfbfbf, 0x8f8f8f8f,0x9f9f9f9f,0xafafafaf,
  353.                             0x7f7f7f7f,0x8f8f8f8f,0x9f9f9f9f, 0x6f6f6f6f,0x7f7f7f7f,0x8f8f8f8f, 0x5f5f5f5f,0x6f6f6f6f,0x7f7f7f7f, 0x4f4f4f4f,0x5f5f5f5f,0x6f6f6f6f,
  354.                             0x3f3f3f3f,0x4f4f4f4f,0x5f5f5f5f, 0x2f2f2f2f,0x3f3f3f3f,0x4f4f4f4f, 0x1f1f1f1f,0x2f2f2f2f,0x3f3f3f3f, 0x0f0f0f0f,0x1f1f1f1f,0x2f2f2f2f,
  355.                             0x00000000,0x0f0f0f0f,0x1f1f1f1f, 0x1f1f1f1f,0x0f0f0f0f,0x1f1f1f1f, 0x2f2f2f2f,0x1f1f1f1f,0x2f2f2f2f, 0x3f3f3f3f,0x2f2f2f2f,0x3f3f3f3f,
  356.                             0x4f4f4f4f,0x3f3f3f3f,0x4f4f4f4f, 0x5f5f5f5f,0x4f4f4f4f,0x5f5f5f5f, 0x6f6f6f6f,0x5f5f5f5f,0x6f6f6f6f, 0x7f7f7f7f,0x6f6f6f6f,0x7f7f7f7f,
  357.                             0x8f8f8f8f,0x7f7f7f7f,0x8f8f8f8f, 0x9f9f9f9f,0x8f8f8f8f,0x9f9f9f9f, 0xafafafaf,0x9f9f9f9f,0xafafafaf, 0xbfbfbfbf,0xafafafaf,0xbfbfbfbf,
  358.                             0xcfcfcfcf,0xbfbfbfbf,0xcfcfcfcf, 0xdfdfdfdf,0xcfcfcfcf,0xdfdfdfdf, 0xefefefef,0xdfdfdfdf,0xefefefef, 0xffffffff,0xefefefef,0xffffffff,
  359.                             0xefefefef,0xffffffff,0xefefefef, 0xdfdfdfdf,0xefefefef,0xdfdfdfdf, 0xcfcfcfcf,0xdfdfdfdf,0xcfcfcfcf, 0xbfbfbfbf,0xcfcfcfcf,0xbfbfbfbf,
  360.                             0xafafafaf,0xbfbfbfbf,0xafafafaf, 0x9f9f9f9f,0xafafafaf,0x9f9f9f9f, 0x8f8f8f8f,0x9f9f9f9f,0x8f8f8f8f, 0x7f7f7f7f,0x8f8f8f8f,0x7f7f7f7f,
  361.                             0x6f6f6f6f,0x7f7f7f7f,0x6f6f6f6f, 0x5f5f5f5f,0x6f6f6f6f,0x5f5f5f5f, 0x4f4f4f4f,0x5f5f5f5f,0x4f4f4f4f, 0x3f3f3f3f,0x4f4f4f4f,0x3f3f3f3f,
  362.                             0x2f2f2f2f,0x3f3f3f3f,0x2f2f2f2f, 0x1f1f1f1f,0x2f2f2f2f,0x1f1f1f1f, 0x0f0f0f0f,0x1f1f1f1f,0x0f0f0f0f, 0x0f0f0f0f,0x1f1f1f1f,0x1f1f1f1f,
  363.                             0x1f1f1f1f,0x2f2f2f2f,0x2f2f2f2f, 0x2f2f2f2f,0x3f3f3f3f,0x3f3f3f3f, 0x3f3f3f3f,0x4f4f4f4f,0x4f4f4f4f, 0x4f4f4f4f,0x5f5f5f5f,0x5f5f5f5f,
  364.                             0x5f5f5f5f,0x6f6f6f6f,0x6f6f6f6f, 0x6f6f6f6f,0x7f7f7f7f,0x7f7f7f7f, 0x7f7f7f7f,0x8f8f8f8f,0x8f8f8f8f, 0x8f8f8f8f,0x9f9f9f9f,0x9f9f9f9f,
  365.                             0x9f9f9f9f,0xafafafaf,0xafafafaf, 0xafafafaf,0xbfbfbfbf,0xbfbfbfbf, 0xbfbfbfbf,0xcfcfcfcf,0xcfcfcfcf, 0xcfcfcfcf,0xdfdfdfdf,0xdfdfdfdf,
  366.                             0xdfdfdfdf,0xefefefef,0xefefefef, 0xefefefef,0xffffffff,0xffffffff, 0xffffffff,0xefefefef,0xefefefef, 0xefefefef,0xdfdfdfdf,0xdfdfdfdf,
  367.                             0xdfdfdfdf,0xcfcfcfcf,0xcfcfcfcf, 0xcfcfcfcf,0xbfbfbfbf,0xbfbfbfbf, 0xbfbfbfbf,0xafafafaf,0xafafafaf, 0xafafafaf,0x9f9f9f9f,0x9f9f9f9f,
  368.                             0x9f9f9f9f,0x8f8f8f8f,0x8f8f8f8f, 0x8f8f8f8f,0x7f7f7f7f,0x7f7f7f7f, 0x7f7f7f7f,0x6f6f6f6f,0x6f6f6f6f, 0x6f6f6f6f,0x5f5f5f5f,0x5f5f5f5f,
  369.                             0x5f5f5f5f,0x4f4f4f4f,0x4f4f4f4f, 0x4f4f4f4f,0x3f3f3f3f,0x3f3f3f3f, 0x3f3f3f3f,0x2f2f2f2f,0x2f2f2f2f, 0x2f2f2f2f,0x1f1f1f1f,0x1f1f1f1f,
  370.                             0x1f1f1f1f,0x0f0f0f0f,0x0f0f0f0f, 0x1f1f1f1f,0x1f1f1f1f,0x0f0f0f0f, 0x2f2f2f2f,0x2f2f2f2f,0x1f1f1f1f, 0x3f3f3f3f,0x3f3f3f3f,0x2f2f2f2f,
  371.                             0x4f4f4f4f,0x4f4f4f4f,0x3f3f3f3f, 0x5f5f5f5f,0x5f5f5f5f,0x4f4f4f4f, 0x6f6f6f6f,0x6f6f6f6f,0x5f5f5f5f, 0x7f7f7f7f,0x7f7f7f7f,0x6f6f6f6f,
  372.                             0x8f8f8f8f,0x8f8f8f8f,0x7f7f7f7f, 0x9f9f9f9f,0x9f9f9f9f,0x8f8f8f8f, 0xafafafaf,0xafafafaf,0x9f9f9f9f, 0xbfbfbfbf,0xbfbfbfbf,0xafafafaf,
  373.                             0xcfcfcfcf,0xcfcfcfcf,0xbfbfbfbf, 0xdfdfdfdf,0xdfdfdfdf,0xcfcfcfcf, 0xefefefef,0xefefefef,0xdfdfdfdf, 0xffffffff,0xffffffff,0xefefefef,
  374.                             0xefefefef,0xefefefef,0xffffffff, 0xdfdfdfdf,0xdfdfdfdf,0xefefefef, 0xcfcfcfcf,0xcfcfcfcf,0xdfdfdfdf, 0xbfbfbfbf,0xbfbfbfbf,0xcfcfcfcf,
  375.                             0xafafafaf,0xafafafaf,0xbfbfbfbf, 0x9f9f9f9f,0x9f9f9f9f,0xafafafaf, 0x8f8f8f8f,0x8f8f8f8f,0x9f9f9f9f, 0x7f7f7f7f,0x7f7f7f7f,0x8f8f8f8f,
  376.                             0x6f6f6f6f,0x6f6f6f6f,0x7f7f7f7f, 0x5f5f5f5f,0x5f5f5f5f,0x6f6f6f6f, 0x4f4f4f4f,0x4f4f4f4f,0x5f5f5f5f, 0x3f3f3f3f,0x3f3f3f3f,0x4f4f4f4f,
  377.                             0x2f2f2f2f,0x2f2f2f2f,0x3f3f3f3f, 0x1f1f1f1f,0x1f1f1f1f,0x2f2f2f2f, 0x0f0f0f0f,0x0f0f0f0f,0x1f1f1f1f, 0x0f0f0f0f,0x0f0f0f0f,0x00000000,
  378.                             0x1f1f1f1f,0x1f1f1f1f,0x00000000, 0x2f2f2f2f,0x2f2f2f2f,0x00000000, 0x3f3f3f3f,0x3f3f3f3f,0x00000000, 0x4f4f4f4f,0x4f4f4f4f,0x00000000,
  379.                             0x5f5f5f5f,0x5f5f5f5f,0x00000000, 0x6f6f6f6f,0x6f6f6f6f,0x00000000, 0x7f7f7f7f,0x7f7f7f7f,0x00000000, 0x8f8f8f8f,0x8f8f8f8f,0x00000000,
  380.                             0x9f9f9f9f,0x9f9f9f9f,0x00000000, 0xafafafaf,0xafafafaf,0x00000000, 0xbfbfbfbf,0xbfbfbfbf,0x00000000, 0xcfcfcfcf,0xcfcfcfcf,0x00000000,
  381.                             0xdfdfdfdf,0xdfdfdfdf,0x00000000, 0xefefefef,0xefefefef,0x00000000, 0xffffffff,0xffffffff,0x00000000, 0xefefefef,0xffffffff,0x00000000,
  382.                             0xdfdfdfdf,0xffffffff,0x00000000, 0xcfcfcfcf,0xffffffff,0x00000000, 0xbfbfbfbf,0xffffffff,0x00000000, 0xafafafaf,0xffffffff,0x00000000,
  383.                             0x9f9f9f9f,0xffffffff,0x00000000, 0x8f8f8f8f,0xffffffff,0x00000000, 0x7f7f7f7f,0xffffffff,0x00000000, 0x6f6f6f6f,0xffffffff,0x00000000,
  384.                             0x5f5f5f5f,0xffffffff,0x00000000, 0x4f4f4f4f,0xffffffff,0x00000000, 0x3f3f3f3f,0xffffffff,0x00000000, 0x2f2f2f2f,0xffffffff,0x00000000,
  385.                             0x1f1f1f1f,0xffffffff,0x00000000, 0x0f0f0f0f,0xffffffff,0x00000000, 0x00000000,0xffffffff,0x00000000, 0x00000000,0xefefefef,0x00000000,
  386.                             0x00000000,0xdfdfdfdf,0x00000000, 0x00000000,0xcfcfcfcf,0x00000000, 0x00000000,0xbfbfbfbf,0x00000000, 0x00000000,0xafafafaf,0x00000000,
  387.                             0x00000000,0x9f9f9f9f,0x00000000, 0x00000000,0x8f8f8f8f,0x00000000, 0x00000000,0x7f7f7f7f,0x00000000, 0x00000000,0x6f6f6f6f,0x00000000,
  388.                             0x00000000,0x5f5f5f5f,0x00000000, 0x00000000,0x4f4f4f4f,0x00000000, 0x00000000,0x3f3f3f3f,0x00000000, 0x00000000,0x2f2f2f2f,0x00000000,
  389.                             0x00000000,0x1f1f1f1f,0x00000000, 0x00000000,0x0f0f0f0f,0x00000000, 0x0f0f0f0f,0x00000000,0x0f0f0f0f, 0x1f1f1f1f,0x00000000,0x1f1f1f1f,
  390.                             0x2f2f2f2f,0x00000000,0x2f2f2f2f, 0x3f3f3f3f,0x00000000,0x3f3f3f3f, 0x4f4f4f4f,0x00000000,0x4f4f4f4f, 0x5f5f5f5f,0x00000000,0x5f5f5f5f,
  391.                             0x6f6f6f6f,0x00000000,0x6f6f6f6f, 0x7f7f7f7f,0x00000000,0x7f7f7f7f, 0x8f8f8f8f,0x00000000,0x8f8f8f8f, 0x9f9f9f9f,0x00000000,0x9f9f9f9f,
  392.                             0xafafafaf,0x00000000,0xafafafaf, 0xbfbfbfbf,0x00000000,0xbfbfbfbf, 0xcfcfcfcf,0x00000000,0xcfcfcfcf, 0xdfdfdfdf,0x00000000,0xdfdfdfdf,
  393.                             0xefefefef,0x00000000,0xefefefef, 0xffffffff,0x00000000,0xffffffff, 0xffffffff,0x00000000,0xefefefef, 0xffffffff,0x00000000,0xdfdfdfdf,
  394.                             0xffffffff,0x00000000,0xcfcfcfcf, 0xffffffff,0x00000000,0xbfbfbfbf, 0xffffffff,0x00000000,0xafafafaf, 0xffffffff,0x00000000,0x9f9f9f9f,
  395.                             0xffffffff,0x00000000,0x8f8f8f8f, 0xffffffff,0x00000000,0x7f7f7f7f, 0xffffffff,0x00000000,0x6f6f6f6f, 0xffffffff,0x00000000,0x5f5f5f5f,
  396.                             0xffffffff,0x00000000,0x4f4f4f4f, 0xffffffff,0x00000000,0x3f3f3f3f, 0xffffffff,0x00000000,0x2f2f2f2f, 0xffffffff,0x00000000,0x1f1f1f1f,
  397.                             0xffffffff,0x00000000,0x0f0f0f0f, 0xffffffff,0x00000000,0x00000000, 0xefefefef,0x00000000,0x00000000, 0xdfdfdfdf,0x00000000,0x00000000,
  398.                             0xcfcfcfcf,0x00000000,0x00000000, 0xbfbfbfbf,0x00000000,0x00000000, 0xafafafaf,0x00000000,0x00000000, 0x9f9f9f9f,0x00000000,0x00000000,
  399.                             0x8f8f8f8f,0x00000000,0x00000000, 0x7f7f7f7f,0x00000000,0x00000000, 0x6f6f6f6f,0x00000000,0x00000000, 0x5f5f5f5f,0x00000000,0x00000000,
  400.                             0x4f4f4f4f,0x00000000,0x00000000, 0x3f3f3f3f,0x00000000,0x00000000, 0x2f2f2f2f,0x00000000,0x00000000, 0x1f1f1f1f,0x00000000,0x00000000,
  401.                             0x0f0f0f0f,0x00000000,0x00000000, 0x00000000,0x0f0f0f0f,0x0f0f0f0f, 0x00000000,0x1f1f1f1f,0x1f1f1f1f, 0x00000000,0x2f2f2f2f,0x2f2f2f2f,
  402.                             0x00000000,0x3f3f3f3f,0x3f3f3f3f, 0x00000000,0x4f4f4f4f,0x4f4f4f4f, 0x00000000,0x5f5f5f5f,0x5f5f5f5f, 0x00000000,0x6f6f6f6f,0x6f6f6f6f,
  403.                             0x00000000,0x7f7f7f7f,0x7f7f7f7f, 0x00000000,0x8f8f8f8f,0x8f8f8f8f, 0x00000000,0x9f9f9f9f,0x9f9f9f9f, 0x00000000,0xafafafaf,0xafafafaf,
  404.                             0x00000000,0xbfbfbfbf,0xbfbfbfbf, 0x00000000,0xcfcfcfcf,0xcfcfcfcf, 0x00000000,0xdfdfdfdf,0xdfdfdfdf, 0x00000000,0xefefefef,0xefefefef,
  405.                             0x00000000,0xffffffff,0xffffffff, 0x00000000,0xefefefef,0xffffffff, 0x00000000,0xdfdfdfdf,0xffffffff, 0x00000000,0xcfcfcfcf,0xffffffff,
  406.                             0x00000000,0xbfbfbfbf,0xffffffff, 0x00000000,0xafafafaf,0xffffffff, 0x00000000,0x9f9f9f9f,0xffffffff, 0x00000000,0x8f8f8f8f,0xffffffff,
  407.                             0x00000000,0x7f7f7f7f,0xffffffff, 0x00000000,0x6f6f6f6f,0xffffffff, 0x00000000,0x5f5f5f5f,0xffffffff, 0x00000000,0x4f4f4f4f,0xffffffff,
  408.                             0x00000000,0x3f3f3f3f,0xffffffff, 0x00000000,0x2f2f2f2f,0xffffffff, 0x00000000,0x1f1f1f1f,0xffffffff, 0x00000000,0x0f0f0f0f,0xffffffff,
  409.                             0x00000000,0x00000000,0xffffffff, 0x00000000,0x00000000,0xefefefef, 0x00000000,0x00000000,0xdfdfdfdf, 0x00000000,0x00000000,0xcfcfcfcf,
  410.                             0x00000000,0x00000000,0xbfbfbfbf, 0x00000000,0x00000000,0xafafafaf, 0x00000000,0x00000000,0x9f9f9f9f, 0x00000000,0x00000000,0x8f8f8f8f,
  411.                             0x00000000,0x00000000,0x7f7f7f7f, 0x00000000,0x00000000,0x6f6f6f6f, 0x00000000,0x00000000,0x5f5f5f5f, 0x00000000,0x00000000,0x4f4f4f4f,
  412.                             0x00000000,0x00000000,0x3f3f3f3f, 0x00000000,0x00000000,0x2f2f2f2f, 0x00000000,0x00000000,0x1f1f1f1f, 0x00000000,0x00000000,0x0f0f0f0f,
  413.                             NULL};
  414.  
  415. UWORD chip ZZZPointer[]  = {0x0000,0x0000,0x0400,0x07C0,0x0000,0x07C0,0x0100,0x0380,
  416.                             0x0000,0x07E0,0x07C0,0x1FF8,0x1FF0,0x3FEC,0x3FF8,0x7FDE,
  417.                             0x3FF8,0x7FBE,0x7FFC,0xFF7F,0x7EFC,0xFFFF,0x7FFC,0xFFFF,
  418.                             0x3FF8,0x7FFE,0x3FF8,0x7FFE,0x1FF0,0x3FFC,0x07C0,0x1FF8,
  419.                             0x0000,0x07E0,0x0000,0x0000};
  420.  
  421. UWORD chip ZoomPointer[] = {0x0000,0x0000,0x0100,0x0000,0x0100,0x0000,0x0000,0x0100,
  422.                             0x0000,0x0100,0x0100,0x0100,0x0100,0x0100,0x0000,0x0000,
  423.                             0xCC66,0x3C78,0x0000,0x0000,0x0100,0x0100,0x0100,0x0100,
  424.                             0x0000,0x0100,0x0000,0x0100,0x0100,0x0000,0x0100,0x0000,
  425.                             0x0000,0x0000};
  426.  
  427. struct NewMenu ProgMenu[] = { NM_TITLE,"Project",0,0,0,0,
  428.  
  429.                               NM_ITEM,"About...","A",NM_ITEMDISABLED,0,0,
  430.  
  431.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  432.  
  433.                               NM_ITEM,"Load picture...","L",NM_ITEMDISABLED,0,0,
  434.  
  435.                               NM_ITEM,"Save picture...","S",NM_ITEMDISABLED,0,0,
  436.  
  437.                               NM_ITEM,"Load palette...","K",NM_ITEMDISABLED,0,0,
  438.  
  439.                               NM_ITEM,"Save palette...","J",NM_ITEMDISABLED,0,0,
  440.  
  441.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  442.  
  443.                               NM_ITEM,"Print...","D",NM_ITEMDISABLED,0,0,
  444.  
  445.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  446.  
  447.                               NM_ITEM,"Quit...","Q",NM_ITEMDISABLED,0,0,
  448.  
  449. /***************************************************************************************/
  450.  
  451.                               NM_TITLE,"Options",0,0,0,0,
  452.  
  453.                               NM_ITEM,"Title",0,NM_ITEMDISABLED,0,0,
  454.                               NM_SUB,"On/Off","O",CHECKIT|CHECKED,0,0,
  455.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  456.                               NM_SUB,"Last time","T",0,0,0,
  457.  
  458.                               NM_ITEM,"Limits...","C",NM_ITEMDISABLED,0,0,
  459.  
  460.                               NM_ITEM,"Iterations",0,NM_ITEMDISABLED,0,0,
  461.                               NM_SUB,"64",0,CHECKIT,~(1<<0),0,
  462.                               NM_SUB,"128",0,CHECKIT,~(1<<1),0,
  463.                               NM_SUB,"192",0,CHECKIT,~(1<<2),0,
  464.                               NM_SUB,"256",0,CHECKIT,~(1<<3),0,
  465.                               NM_SUB,"320",0,CHECKIT|CHECKED,~(1<<4),0,
  466.                               NM_SUB,"384",0,CHECKIT,~(1<<5),0,
  467.                               NM_SUB,"448",0,CHECKIT,~(1<<6),0,
  468.                               NM_SUB,"512",0,CHECKIT,~(1<<7),0,
  469.                               NM_SUB,"1024",0,CHECKIT,~(1<<8),0,
  470.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  471.                               NM_SUB,"Custom...","I",CHECKIT,~(1<<10),0,
  472.  
  473.                               NM_ITEM,"Priority",0,0,0,0,
  474.                               NM_SUB,"-5","%",CHECKIT,~(1<<0),0,
  475.                               NM_SUB,"-4","$",CHECKIT,~(1<<1),0,
  476.                               NM_SUB,"-3","£",CHECKIT,~(1<<2),0,
  477.                               NM_SUB,"-2","\"",CHECKIT,~(1<<3),0,
  478.                               NM_SUB,"-1","!",CHECKIT,~(1<<4),0,
  479.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  480.                               NM_SUB," 0","0",CHECKIT|CHECKED,~(1<<6),0,
  481.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  482.                               NM_SUB,"+1","1",CHECKIT,~(1<<8),0,
  483.                               NM_SUB,"+2","2",CHECKIT,~(1<<9),0,
  484.                               NM_SUB,"+3","3",CHECKIT,~(1<<10),0,
  485.                               NM_SUB,"+4","4",CHECKIT,~(1<<11),0,
  486.                               NM_SUB,"+5","5",CHECKIT,~(1<<12),0,
  487.  
  488.                               NM_ITEM,"Color mapping",0,0,0,0,
  489.                               NM_SUB,"Repeated",0,CHECKIT,~(1<<0),0,
  490.                               NM_SUB,"Spread",0,CHECKIT|CHECKED,~(1<<1),0,
  491.  
  492.                               NM_ITEM,"Precision",0,0,0,0,
  493.                               NM_SUB,"Integer",0,CHECKIT|CHECKED,~(1<<0),0,
  494.                               NM_SUB,"Real",0,CHECKIT,~(1<<1),0,
  495.  
  496. /***************************************************************************************/
  497.  
  498.                               NM_TITLE,"Calculate",0,0,0,0,
  499.  
  500.                               NM_ITEM,"PreView","W",NM_ITEMDISABLED,0,0,
  501.  
  502.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  503.  
  504.                               NM_ITEM,"ReCalculate","R",NM_ITEMDISABLED,0,0,
  505.  
  506.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  507.  
  508.                               NM_ITEM,"Undo","U",NM_ITEMDISABLED,0,0,
  509.  
  510.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  511.  
  512.                               NM_ITEM,"Zoom","Z",NM_ITEMDISABLED,0,0,
  513.  
  514.                               NM_ITEM,"Stop","X",0,0,0,
  515.  
  516. /***************************************************************************************/
  517.  
  518.                               NM_TITLE,"Video",0,0,0,0,
  519.  
  520.                               NM_ITEM,"Cycle",0,NM_ITEMDISABLED,0,0,
  521.                               NM_SUB,"Forward",">",0,0,0,
  522.                               NM_SUB,"Backward","<",0,0,0,
  523.                               NM_SUB,NM_BARLABEL,0,0,0,0,
  524.                               NM_SUB,"Delay...","-",0,0,0,
  525.  
  526.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  527.  
  528.                               NM_ITEM,"Palette...","P",NM_ITEMDISABLED,0,0,
  529.  
  530.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  531.  
  532.                               NM_ITEM,"Screen mode...","V",NM_ITEMDISABLED,0,0,
  533.  
  534.                               NM_ITEM,NM_BARLABEL,0,0,0,0,
  535.  
  536.                               NM_ITEM,"Font settings...","F",NM_ITEMDISABLED,0,0,
  537.  
  538.                               NM_END,0,0,0,0,0 };
  539.  
  540.  
  541. struct Menu *MAINMENU = NULL;
  542.  
  543. struct BitMap *MYBITMAP = NULL;
  544.  
  545. struct Task *THISTASK = NULL;
  546.  
  547. struct TextFont *NEWFONT = NULL;
  548.  
  549. struct ILBMInfo MYILBM;
  550.  
  551. struct MandelChunk MANDChunk;
  552.  
  553. struct MandelChunk *MANDChunkTmp = NULL;
  554.  
  555. LONG IlbmProps [] = { ID_ILBM, ID_BMHD, ID_ILBM, ID_CMAP, ID_ILBM, ID_CAMG, ID_ILBM, ID_MAND, TAG_END };
  556.  
  557. LONG IlbmCollects [] = { TAG_END };
  558.  
  559. LONG IlbmStops [] = { ID_ILBM, ID_BODY, TAG_END };
  560.  
  561. IMPORT BOOL ModifyPalette (struct Window *,WORD,WORD,WORD,WORD,ULONG *);
  562.  
  563. IMPORT BOOL Cycle (struct Window *,ULONG,BOOL);
  564.  
  565. IMPORT WORD __asm MandInt (register __d0 WORD,register __d1 LONG,register __d2 LONG);
  566.  
  567. IMPORT LONG QueryMandPic (struct ILBMInfo *,struct MandelChunk **,UBYTE *);
  568.  
  569. IMPORT LONG LoadMandPic (struct ILBMInfo *,UBYTE *);
  570.  
  571. IMPORT LONG SaveMandPic (struct ILBMInfo *,struct Chunk *,struct Chunk *,UBYTE *);
  572.  
  573. IMPORT LONG LoadPalette (struct ILBMInfo *,UBYTE *);
  574.  
  575. IMPORT LONG SavePalette (struct ILBMInfo *,struct Chunk *,UBYTE *);
  576.  
  577. VOID PutPointer (struct Window *Win,UWORD *PointerImage,WORD Width,WORD Height,WORD XOrigin,WORD YOrigin,UBYTE Type)
  578. {
  579.   switch (Type)
  580.   {
  581.      case 0: SetWindowPointer (Win,TAG_END);
  582.  
  583.              break;
  584.  
  585.      case 1: SetWindowPointer (Win,WA_BusyPointer,TRUE,WA_PointerDelay,TRUE,TAG_END);
  586.  
  587.              break;
  588.  
  589.     default: SetPointer (Win,PointerImage,Height,Width,XOrigin,YOrigin);
  590.   }
  591. }
  592.  
  593. UBYTE GetMaxPlanes (ULONG ModeID)
  594. {
  595. DisplayInfoHandle DisplayHandle;
  596.  
  597. struct DimensionInfo DimensionInfo;
  598.  
  599. UBYTE Planes = 0;
  600.  
  601.   DisplayHandle = FindDisplayInfo (ModeID);
  602.  
  603.   if (GetDisplayInfoData (DisplayHandle,(UBYTE *) &DimensionInfo,sizeof (struct DimensionInfo),DTAG_DIMS,ModeID))
  604.   {
  605.      Planes = DimensionInfo.MaxDepth;
  606.   }
  607.  
  608.   else Fail (DimensionInfoError,20L);
  609.  
  610.   return Planes;
  611. }
  612.  
  613. LONG CheckGFX (VOID)
  614. {
  615. BOOL AGA = FALSE,RTG = FALSE;
  616.  
  617. ULONG ModeID = INVALID_ID;
  618.  
  619.   if (GetMaxPlanes (LORES_KEY) == MAX_DEPTH) AGA = TRUE;
  620.  
  621.   while (((ModeID = NextDisplayInfo (ModeID)) != INVALID_ID) && RTG == FALSE)
  622.   {
  623.     if (GetMaxPlanes (ModeID) > MAX_DEPTH) RTG = TRUE;
  624.   }
  625.  
  626.   if (RTG && AGA) return 3L;
  627.  
  628.   if (RTG) return 2L;
  629.  
  630.   if (AGA) return 1L;
  631.  
  632.   return NULL;
  633. }
  634.  
  635. BOOL CheckEHB (ULONG ModeID)
  636. {
  637. DisplayInfoHandle DisplayHandle;
  638.  
  639. struct DisplayInfo DisplayInfo;
  640.  
  641. BOOL IsEHB = FALSE;
  642.  
  643.   DisplayHandle = FindDisplayInfo (ModeID);
  644.  
  645.   if (GetDisplayInfoData (DisplayHandle,(UBYTE *) &DisplayInfo,sizeof (struct DisplayInfo),DTAG_DISP,ModeID))
  646.   {
  647.      if (DisplayInfo.PropertyFlags & DIPF_IS_EXTRAHALFBRITE) IsEHB = TRUE;
  648.   }
  649.  
  650.   else Fail (DisplayInfoError,20L);
  651.  
  652.   return IsEHB;
  653. }
  654.  
  655. ULONG CheckFPU (UWORD CpuFlags)
  656. {
  657.   if (AFF_68060 & CpuFlags) return 68884L;
  658.  
  659.   if (AFF_FPU40 & CpuFlags) return 68883L;
  660.  
  661.   if (AFF_68882 & CpuFlags) return 68882L;
  662.  
  663.   if (AFF_68881 & CpuFlags) return 68881L;
  664.  
  665.   return NULL;
  666. }
  667.  
  668. VOID CloseDisplay (struct ILBMInfo *Ilbm,CPTR *VInfo)
  669. {
  670.   if (WMASK & MASK)
  671.   {
  672.      ClearMenuStrip (Ilbm->win);
  673.  
  674.      PutPointer (Ilbm->win,0,0,0,0,0,0);
  675.  
  676.      CloseWindow (Ilbm->win);
  677.  
  678.      Ilbm->win = NULL;
  679.  
  680.      Ilbm->wrp = NULL;
  681.  
  682.      MASK ^= WMASK;
  683.   }
  684.  
  685.   if (VMASK & MASK)
  686.   {
  687.      FreeVisualInfo (VInfo);
  688.  
  689.      MASK ^= VMASK;
  690.   }
  691.  
  692.   if (SMASK & MASK)
  693.   {
  694.      CloseScreen (Ilbm->scr);
  695.  
  696.      Ilbm->scr = NULL;
  697.  
  698.      Ilbm->vp  = NULL;
  699.  
  700.      Ilbm->srp = NULL;
  701.  
  702.      MASK ^= SMASK;
  703.   }
  704.  
  705.   if (FMASK & MASK)
  706.   {
  707.      CloseFont (NEWFONT);
  708.  
  709.      MASK ^= FMASK;
  710.   }
  711. }
  712.  
  713. struct Window *OpenDisplay (struct ILBMInfo *Ilbm,WORD Width,WORD Height,WORD Depth,ULONG ModeID)
  714. {
  715. struct Screen *Scr;
  716.  
  717. struct Window *Win = NULL;
  718.  
  719.   if (Scr = OpenIdScreen (Ilbm,Width,Height,Depth,ModeID))
  720.   {
  721.      Win = OpenWindowTags (NULL,
  722.                            WA_Left,Scr->LeftEdge,
  723.                            WA_Top,Scr->TopEdge,
  724.                            WA_Width,Scr->Width,
  725.                            WA_Height,Scr->Height,
  726.                            WA_ScreenTitle,VERSION,
  727.                            WA_CustomScreen,Scr,
  728.                            WA_MouseQueue,1L,
  729.                            WA_IDCMP,IDCMP_STANDARD,
  730.                            WA_Flags,WFLG_STANDARD,
  731.                            TAG_END);
  732.  
  733.      if (! Win)
  734.      {
  735.         if (Scr) CloseScreen (Scr);
  736.  
  737.         return NULL;
  738.      }
  739.  
  740.      Ilbm->scr = Scr;
  741.  
  742.      Ilbm->win = Win;
  743.  
  744.      Ilbm->vp  = &(Scr->ViewPort);
  745.  
  746.      Ilbm->srp = &(Scr->RastPort);
  747.  
  748.      Ilbm->wrp = Win->RPort;
  749.  
  750.      Ilbm->Bmhd.w = Ilbm->win->Width;
  751.  
  752.      Ilbm->Bmhd.h = Ilbm->win->Height;
  753.  
  754.      Ilbm->Bmhd.nPlanes = Ilbm->wrp->BitMap->Depth;
  755.   }
  756.  
  757.   return (Win);
  758. }
  759.  
  760. struct Screen *OpenIdScreen (struct ILBMInfo *Ilbm,WORD Width,WORD Height,WORD Depth,ULONG ModeID)
  761. {
  762. struct Rectangle Spos,DClip,TxtO,StdO,MaxO,UClip;
  763.  
  764. struct Rectangle *UClipp;
  765.  
  766. struct Screen *Scr;
  767.  
  768. LONG ErrorCode = NULL,TryNew;
  769.  
  770. ULONG BitMapTag,PassedTags;
  771.  
  772.   if (! Ilbm) return (NULL);
  773.  
  774.   TryNew = ((QueryOverscan (ModeID,&TxtO,OSCAN_TEXT)) && (QueryOverscan (ModeID,&StdO,OSCAN_STANDARD)) && (QueryOverscan (ModeID,&MaxO,OSCAN_MAX)));
  775.  
  776.   if (TryNew)
  777.   {
  778.      if (Ilbm->Video) Ilbm->ucliptype = OSCAN_VIDEO;
  779.  
  780.      if ((Ilbm->ucliptype) && (QueryOverscan (ModeID,&UClip,Ilbm->ucliptype))) UClipp = &UClip;
  781.  
  782.      else UClipp = NULL;
  783.  
  784.      ClipIt (Width,Height,&Spos,&DClip,&TxtO,&StdO,&MaxO,UClipp,Ilbm->IFFPFlags & IFFPF_NOCENTER ? TRUE : FALSE);
  785.  
  786.      BitMapTag = ((Ilbm->brbitmap) && (Ilbm->stype & CUSTOMBITMAP)) ? SA_BitMap : TAG_IGNORE;
  787.  
  788.      PassedTags = Ilbm->stags ? TAG_MORE : TAG_IGNORE;
  789.  
  790.      Scr = OpenScreenTags (NULL,
  791.                            SA_DisplayID,   ModeID,
  792.                            SA_Type,        Ilbm->stype,
  793.                            SA_Top,         Spos.MinY,
  794.                            SA_Left,        Spos.MinX,
  795.                            SA_Width,       Width,
  796.                            SA_Height,      Height,
  797.                            SA_Depth,       Depth,
  798.                            SA_DClip,       &DClip,
  799.                            SA_AutoScroll,  Ilbm->Autoscroll,
  800.                            SA_Colors32,    PALETTE,
  801.                            SA_Pens,        PENS,
  802.                            SA_Interleaved, TRUE,
  803.                            SA_Font,        &MYFONTSTRUCT,
  804.                            SA_Title,       VERSION,
  805.                            SA_ErrorCode,   &ErrorCode,
  806.                            SA_ShowTitle,   Ilbm->TBState,
  807.                            BitMapTag,      Ilbm->brbitmap,
  808.                            PassedTags,     Ilbm->stags,
  809.                            TAG_END);
  810.  
  811.      if (! Scr)
  812.      {
  813.         switch (ErrorCode)
  814.         {
  815.                  case OSERR_NOMONITOR   : Fail (NoMonitor,20L);
  816.  
  817.                                           break;
  818.  
  819.                  case OSERR_NOCHIPS     : Fail (NoChips,20L);
  820.  
  821.                                           break;
  822.  
  823.                  case OSERR_NOMEM       : Fail (NoMem,20L);
  824.  
  825.                                           break;
  826.  
  827.                  case OSERR_NOCHIPMEM   : Fail (NoChipMem,20L);
  828.  
  829.                                           break;
  830.  
  831.                  case OSERR_PUBNOTUNIQUE: Fail (PubNotUnique,20L);
  832.  
  833.                                           break;
  834.  
  835.                  case OSERR_UNKNOWNMODE : Fail (UnknownMode,20L);
  836.  
  837.                                           break;
  838.  
  839.                  case OSERR_TOODEEP     : Fail (ScreenTooDeep,20L);
  840.  
  841.                                           break;
  842.  
  843.                  case OSERR_ATTACHFAIL  : Fail (AttachScreen,20L);
  844.  
  845.                                           break;
  846.  
  847.                  case OSERR_NOTAVAILABLE: Fail (ModeNotAvailableError,20L);
  848.  
  849.                                           break;
  850.  
  851.                  default                : Fail (UnknownScrError,20L);
  852.  
  853.                                           break;
  854.         }
  855.  
  856.         return NULL;
  857.      }
  858.   }
  859.  
  860.   else return NULL;
  861.  
  862.   if (Ilbm->Notransb)
  863.   {
  864.      VideoControlTags (Scr->ViewPort.ColorMap,VTAG_BORDERNOTRANS_SET,TRUE,TAG_END);
  865.  
  866.      MakeScreen (Scr);
  867.  
  868.      RethinkDisplay ();
  869.   }
  870.  
  871.   return (Scr);
  872. }
  873.  
  874. ULONG ModeFallBack (ULONG OldModeID,WORD Width,WORD Height,WORD Depth)
  875. {
  876. ULONG NewModeID = LORES_KEY,BestModeID;
  877.  
  878. struct TagItem Tags [6];
  879.  
  880.   Tags [0].ti_Tag   = BIDTAG_DIPFMustHave;
  881.  
  882.   Tags [0].ti_Data  = (OldModeID & HAM ? DIPF_IS_HAM : 0);
  883.  
  884.   Tags [0].ti_Data |= (OldModeID & EXTRA_HALFBRITE ? DIPF_IS_EXTRAHALFBRITE : 0);
  885.  
  886.   Tags [1].ti_Tag   = BIDTAG_NominalWidth;
  887.  
  888.   Tags [1].ti_Data  = Width; // bmhd->XAspect; // wide;
  889.  
  890.   Tags [2].ti_Tag   = BIDTAG_NominalHeight;
  891.  
  892.   Tags [2].ti_Data  = Height; // bmhd->YAspectHeight; // high;
  893.  
  894.   Tags [3].ti_Tag   = BIDTAG_Depth;
  895.  
  896.   Tags [3].ti_Data  = Depth;
  897.  
  898.   Tags [4].ti_Tag   = BIDTAG_SourceID;
  899.  
  900.   Tags [4].ti_Data  = (FindDisplayInfo (OldModeID) ? OldModeID : (OldModeID & (~(MONITOR_ID_MASK|SPRITES|GENLOCK_AUDIO|GENLOCK_VIDEO|VP_HIDE))));
  901.  
  902.   Tags [5].ti_Tag   = TAG_END;
  903.  
  904.   BestModeID = BestModeIDA (Tags);
  905.  
  906.   if (BestModeID != INVALID_ID) NewModeID = BestModeID;
  907.  
  908.   return (NewModeID);
  909. }
  910.  
  911. VOID ClipIt (WORD wide,WORD high,struct Rectangle *spos,struct Rectangle *dclip,struct Rectangle *txto, struct Rectangle *stdo,struct Rectangle *maxo, struct Rectangle *uclip,BOOL NoCenter)
  912. {
  913. struct Rectangle *besto;
  914.  
  915. WORD minx, maxx, miny, maxy;
  916.  
  917. WORD txtw, txth, stdw, stdh, bestw, besth;
  918.  
  919.     /* get the txt, std and max widths and heights */
  920.  
  921.     txtw = txto->MaxX - txto->MinX + 1;
  922.  
  923.     txth = txto->MaxY - txto->MinY + 1;
  924.  
  925.     stdw = stdo->MaxX - stdo->MinX + 1;
  926.  
  927.     stdh = stdo->MaxY - stdo->MinY + 1;
  928.  
  929.     if ((wide <= txtw) && (high <= txth))
  930.     {
  931.     besto = txto;
  932.  
  933.     bestw = txtw;
  934.  
  935.     besth = txth;
  936.     }
  937.  
  938.     else
  939.     {
  940.     besto = stdo;
  941.  
  942.     bestw = stdw;
  943.  
  944.     besth = stdh;
  945.     }
  946.  
  947.     if (uclip)
  948.     {
  949.     *dclip = *uclip;
  950.  
  951.         spos->MinX = uclip->MinX;
  952.  
  953.     spos->MinY = uclip->MinY;
  954.     }
  955.  
  956.     else
  957.     {
  958.     /* CENTER the screen based on best oscan prefs
  959.      * but confine dclip within max oscan limits
  960.      *
  961.      * FIX MinX first */
  962.  
  963.     spos->MinX = minx = besto->MinX - ((wide - bestw) >> 1);
  964.  
  965.     maxx = wide + minx - 1;
  966.  
  967.     if (maxx > maxo->MaxX)  maxx = maxo->MaxX;    /* too right */
  968.  
  969.     if (minx < maxo->MinX)
  970.         {
  971.         minx = maxo->MinX;    /* too left  */
  972.  
  973.         /* if we want left edge of screen not clipped */
  974.  
  975.         if (NoCenter) spos->MinX = minx;
  976.     }
  977.  
  978.     /* FIX MinY */
  979.  
  980.     spos->MinY = miny = besto->MinY - ((high - besth) >> 1);
  981.  
  982.     /* if lower than top of txto, move up */
  983.  
  984.     spos->MinY = miny = MIN (spos->MinY,txto->MinY);
  985.  
  986.     maxy = high + miny - 1;
  987.  
  988.     if (maxy > maxo->MaxY)  maxy = maxo->MaxY;    /* too down  */
  989.  
  990.     if (miny < maxo->MinY)
  991.         {
  992.        miny = maxo->MinY;    /* too up    */
  993.  
  994.        /* if we want top of screen not clipped */
  995.  
  996.        if (NoCenter) spos->MinY = miny;
  997.         }
  998.  
  999.     /* SET up dclip */
  1000.  
  1001.     dclip->MinX = minx;
  1002.  
  1003.     dclip->MinY = miny;
  1004.  
  1005.     dclip->MaxX = maxx;
  1006.  
  1007.     dclip->MaxY = maxy;
  1008.     }
  1009. }
  1010.  
  1011. LONG MakeDisplay (struct ILBMInfo *Ilbm)
  1012. {
  1013.   if (Ilbm->IFFPFlags & IFFPF_USERMODE)    Ilbm->camg = Ilbm->usermodeid;
  1014.  
  1015.   Ilbm->Bmhd.w = MAX (MIN_WIDTH,Ilbm->Bmhd.w);
  1016.  
  1017.   Ilbm->Bmhd.h = MAX (MIN_HEIGHT,Ilbm->Bmhd.h);
  1018.  
  1019.   Ilbm->Bmhd.nPlanes = MIN (MAX_DEPTH,MAX (MIN_DEPTH,Ilbm->Bmhd.nPlanes));
  1020.  
  1021.   if (ModeNotAvailable (Ilbm->camg) || (Ilbm->IFFPFlags & IFFPF_BESTFIT))
  1022.   {
  1023.      Ilbm->camg = ModeFallBack (Ilbm->camg,Ilbm->Bmhd.w,Ilbm->Bmhd.h,Ilbm->Bmhd.nPlanes);
  1024.  
  1025.      if (ModeNotAvailable (Ilbm->camg))
  1026.      {
  1027.         Fail (ModeNotAvailableError,20L);
  1028.  
  1029.         return NULL;
  1030.      }
  1031.   }
  1032.  
  1033.   if (! (OpenDisplay (Ilbm,MAX (Ilbm->Bmhd.pageWidth,Ilbm->Bmhd.w),MAX (Ilbm->Bmhd.pageHeight,Ilbm->Bmhd.h),Ilbm->Bmhd.nPlanes,Ilbm->camg))) return NULL;
  1034.  
  1035.   MASK |= SMASK;
  1036.  
  1037.   MASK |= WMASK;
  1038.  
  1039.   if (! (VINFO = GetVisualInfo (Ilbm->scr,TAG_END)))
  1040.   {
  1041.      Fail (VisualInfoError,20L);
  1042.  
  1043.      return NULL;
  1044.   }
  1045.  
  1046.   MASK |= VMASK;
  1047.  
  1048.   if (! (LayoutMenus (MAINMENU,VINFO,GTMN_TextAttr,&MYFONTSTRUCT,GTMN_NewLookMenus,TRUE,TAG_END)))
  1049.   {
  1050.      Fail (FontError,20L);
  1051.  
  1052.      return NULL;
  1053.   }
  1054.  
  1055.   SetMenuStrip (Ilbm->win,MAINMENU);
  1056.  
  1057.   return (Ilbm->vp->ColorMap->Count);
  1058. }
  1059.  
  1060. VOID ShowTime (struct Window *Win,TEXT *String,ULONG Sec)
  1061. {
  1062.   sprintf (BAR_STRING,"%s %uh %um %us",String,Sec / 3600L,(Sec / 60L) % 60L,Sec % 60L);
  1063.  
  1064.   SetWindowTitles (Win,(TEXT *) ~0,BAR_STRING);
  1065. }
  1066.  
  1067. VOID SaveCoords (VOID)
  1068. {
  1069.   URMIN = RMIN;
  1070.  
  1071.   URMAX = RMAX;
  1072.  
  1073.   UIMIN = IMIN;
  1074.  
  1075.   UIMAX = IMAX;
  1076. }
  1077.  
  1078. VOID RestoreCoords (VOID)
  1079. {
  1080.   RMIN = URMIN;
  1081.  
  1082.   RMAX = URMAX;
  1083.  
  1084.   IMIN = UIMIN;
  1085.  
  1086.   IMAX = UIMAX;
  1087. }
  1088.  
  1089. BOOL NewCoords (struct Window *Win,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
  1090. {
  1091. long double KReal,KImag;
  1092.  
  1093.   if (((a2 - a1) < 2L) || ((b2 - b1) < 2L)) return FALSE;
  1094.  
  1095.   KReal = fabs (RMAX-RMIN) / ((long double) Win->Width);
  1096.  
  1097.   KImag = fabs (IMAX-IMIN) / ((long double) Win->Height);
  1098.  
  1099.   SaveCoords ();
  1100.  
  1101.   RMAX = RMIN + ((long double) a2 * KReal);
  1102.  
  1103.   IMIN = IMAX - ((long double) b2 * KImag);
  1104.  
  1105.   RMIN += ((long double) a1 * KReal);
  1106.  
  1107.   IMAX -= ((long double) b1 * KImag);
  1108.  
  1109.   return TRUE;
  1110. }
  1111.  
  1112. VOID AdjustRatio (long double *RMin,long double *IMax,long double *RMax,long double *IMin,WORD ScrWidth,WORD ScrHeight,BOOL KeepReal)
  1113. {
  1114. long double RWidth,IHeight,RCenter,ICenter;
  1115.  
  1116.   IHeight = *IMax - *IMin;
  1117.  
  1118.   RWidth  = *RMax - *RMin;
  1119.  
  1120.   if (KeepReal)
  1121.   {
  1122.      ICenter = *IMin + (IHeight / 2.0);
  1123.  
  1124.      IHeight = (RWidth * ScrHeight) / ScrWidth;
  1125.  
  1126.      *IMax = ICenter + (IHeight / 2.0);
  1127.  
  1128.      *IMin = ICenter - (IHeight / 2.0);
  1129.   }
  1130.  
  1131.   else
  1132.   {
  1133.      RCenter = *RMin + (RWidth / 2.0);
  1134.  
  1135.      RWidth = (IHeight * ScrWidth) / ScrHeight;
  1136.  
  1137.      *RMax = RCenter + (RWidth / 2.0);
  1138.  
  1139.      *RMin = RCenter - (RWidth / 2.0);
  1140.   }
  1141. }
  1142.  
  1143. LONG About (struct Window *Win)
  1144. {
  1145. struct EasyStruct MyReq_1 = { sizeof (struct EasyStruct),0,"Informations requester","      " VERSION COPYRIGHT "\n\n           " AUTHOR "\n\n" ADDRESS EMAIL "\n\n\n    This program is GiftWare !     \n\n","Ok|More..." };
  1146.  
  1147. struct EasyStruct MyReq_2 = { sizeof (struct EasyStruct),0,"Workgroup","        Greetings & thanks to\n\nClaudio Pucci: Debug,Docs,Install\n\nSergio Tassi: Test,Palettes,GUILook\n\nGiuseppe Staffelli: RTG Debug\n\n\n         Crime do not pay !\n\n\n       Call Double Impact BBS\n\n   +39-81-5881319/5889963 24/24h\n\nMultiline ISDN  by Paolo Carotenuto\n\n","Ok" };
  1148.  
  1149. LONG More;
  1150.  
  1151.   More = EasyRequest (Win,&MyReq_1,0);
  1152.  
  1153.   if (! More) EasyRequest (Win,&MyReq_2,0);
  1154.  
  1155.   return More;
  1156. }
  1157.  
  1158. LONG Choice (struct Window *Win,TEXT *Title,TEXT *String)
  1159. {
  1160. struct EasyStruct MyReq = { sizeof (struct EasyStruct),NULL,0,0,"Yes|No" };
  1161.  
  1162.   MyReq.es_Title = Title;
  1163.  
  1164.   MyReq.es_TextFormat = String;
  1165.  
  1166.   return EasyRequest (Win,&MyReq,0);
  1167. }
  1168.  
  1169. BOOL ShowCoords (struct Window *Win)
  1170. {
  1171. struct Gadget *GadList = NULL,*StringGad_1,*StringGad_2,*StringGad_3,*StringGad_4;
  1172.  
  1173. struct Gadget *MyButtonGad,*MyCheckBoxGad,*MyGad = NULL;
  1174.  
  1175. struct Window *GadWin;
  1176.  
  1177. struct IntuiMessage *Message;
  1178.  
  1179. BOOL NewLimits = FALSE,Exit = FALSE,Accept = FALSE,Reset = FALSE,Ratio = FALSE,KeepReal = TRUE;
  1180.  
  1181. TEXT String [MAXCHARS];
  1182.  
  1183. UWORD MyCode = 0;
  1184.  
  1185. ULONG MyClass = NULL;
  1186.  
  1187. long double Tmp_RMIN = RMIN,Tmp_IMAX = IMAX,Tmp_RMAX = RMAX,Tmp_IMIN = IMIN;
  1188.  
  1189.   TEXTGAD.ng_VisualInfo = BUTTONGAD.ng_VisualInfo = CHECKBOXGAD.ng_VisualInfo  = VINFO;
  1190.  
  1191.   MyCheckBoxGad = CreateContext (&GadList);
  1192.  
  1193.   CHECKBOXGAD.ng_LeftEdge   = 14;
  1194.  
  1195.   CHECKBOXGAD.ng_TopEdge    = 120;
  1196.  
  1197.   CHECKBOXGAD.ng_Width      = 20;
  1198.  
  1199.   CHECKBOXGAD.ng_Height     = 20;
  1200.  
  1201.   CHECKBOXGAD.ng_GadgetText = "_Keep real limits";
  1202.  
  1203.   CHECKBOXGAD.ng_Flags      = PLACETEXT_RIGHT;
  1204.  
  1205.   CHECKBOXGAD.ng_GadgetID   = KEEP;
  1206.  
  1207.   MyCheckBoxGad = CreateGadget (CHECKBOX_KIND,MyCheckBoxGad,&CHECKBOXGAD,GTCB_Checked,TRUE,GT_Underscore,'_',TAG_END);
  1208.  
  1209.   BUTTONGAD.ng_LeftEdge   = 14;
  1210.  
  1211.   BUTTONGAD.ng_TopEdge    = 140;
  1212.  
  1213.   BUTTONGAD.ng_Width      = 80;
  1214.  
  1215.   BUTTONGAD.ng_Height     = 20;
  1216.  
  1217.   BUTTONGAD.ng_GadgetText = "_Accept";
  1218.  
  1219.   BUTTONGAD.ng_GadgetID   = ACCEPT;
  1220.  
  1221.   MyButtonGad = CreateGadget (BUTTON_KIND,MyCheckBoxGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1222.  
  1223.   BUTTONGAD.ng_LeftEdge  += (14 + BUTTONGAD.ng_Width);
  1224.  
  1225.   BUTTONGAD.ng_GadgetText = "Rat_io";
  1226.  
  1227.   BUTTONGAD.ng_GadgetID   = RATIO;
  1228.  
  1229.   MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1230.  
  1231.   BUTTONGAD.ng_LeftEdge  += (14 + BUTTONGAD.ng_Width);
  1232.  
  1233.   BUTTONGAD.ng_GadgetText = "Re_set";
  1234.  
  1235.   BUTTONGAD.ng_GadgetID   = RESET;
  1236.  
  1237.   MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1238.  
  1239.   BUTTONGAD.ng_LeftEdge  += (14 + BUTTONGAD.ng_Width);
  1240.  
  1241.   BUTTONGAD.ng_GadgetText = "_Cancel";
  1242.  
  1243.   BUTTONGAD.ng_GadgetID   = CANCEL;
  1244.  
  1245.   MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1246.  
  1247.   BUTTONGAD.ng_LeftEdge  += (14 + BUTTONGAD.ng_Width);
  1248.  
  1249.   TEXTGAD.ng_LeftEdge     = 54;
  1250.  
  1251.   TEXTGAD.ng_TopEdge      = 14;
  1252.  
  1253.   TEXTGAD.ng_Width        = 268;
  1254.  
  1255.   TEXTGAD.ng_Height       = 14;
  1256.  
  1257.   TEXTGAD.ng_GadgetText   = "_Left";
  1258.  
  1259.   TEXTGAD.ng_Flags        = PLACETEXT_LEFT;
  1260.  
  1261.   sprintf (String,"%+2.80lf",RMIN);
  1262.  
  1263.   StringGad_1 = CreateGadget (STRING_KIND,MyButtonGad,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
  1264.  
  1265.   TEXTGAD.ng_TopEdge     += (14 + TEXTGAD.ng_Height);
  1266.  
  1267.   TEXTGAD.ng_GadgetText   = "_Top ";
  1268.  
  1269.   sprintf (String,"%+2.80lf",IMAX);
  1270.  
  1271.   StringGad_2 = CreateGadget (STRING_KIND,StringGad_1,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
  1272.  
  1273.   TEXTGAD.ng_TopEdge     += (14 + TEXTGAD.ng_Height);
  1274.  
  1275.   TEXTGAD.ng_GadgetText   = "_Right";
  1276.  
  1277.   TEXTGAD.ng_Flags        = PLACETEXT_RIGHT;
  1278.  
  1279.   sprintf (String,"%+2.80lf",RMAX);
  1280.  
  1281.   StringGad_3 = CreateGadget (STRING_KIND,StringGad_2,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
  1282.  
  1283.   TEXTGAD.ng_TopEdge     += (14 + TEXTGAD.ng_Height);
  1284.  
  1285.   TEXTGAD.ng_GadgetText   = "_Bottom";
  1286.  
  1287.   sprintf (String,"%+2.80lf",IMIN);
  1288.  
  1289.   StringGad_4 = CreateGadget (STRING_KIND,StringGad_3,&TEXTGAD,GTST_String,String,STRINGA_ReplaceMode,TRUE,GTST_MaxChars,MAXCHARS,GT_Underscore,'_',TAG_END);
  1290.  
  1291.   if (StringGad_4)
  1292.   {
  1293.      GadWin = OpenWindowTags (NULL,WA_Left,Win->LeftEdge + 10,
  1294.                                    WA_Top,Win->TopEdge + 15,
  1295.                                    WA_Width,BUTTONGAD.ng_LeftEdge + 10,
  1296.                                    WA_Height,BUTTONGAD.ng_TopEdge + BUTTONGAD.ng_Height + 14 + 15,
  1297.                                    WA_Title,"Coordinates requester",
  1298.                                    WA_ScreenTitle,"Insert new range...",
  1299.                                    WA_CustomScreen,Win->WScreen,
  1300.                                    WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|STRINGIDCMP|BUTTONIDCMP,
  1301.                                    WA_Flags,WFLG_ACTIVATE|WFLG_DRAGBAR|WFLG_SIMPLE_REFRESH|WFLG_GIMMEZEROZERO|WFLG_RMBTRAP,
  1302.                                    WA_Gadgets,GadList,
  1303.                                    TAG_END);
  1304.      if (GadWin)
  1305.      {
  1306.         GT_RefreshWindow (GadWin,NULL);
  1307.  
  1308.         do {  WaitPort (GadWin->UserPort);
  1309.  
  1310.               if (Message = (struct IntuiMessage *) GT_GetIMsg (GadWin->UserPort))
  1311.               {
  1312.                      MyGad = (struct Gadget *) Message->IAddress;
  1313.  
  1314.                      MyClass = Message->Class;
  1315.  
  1316.                      MyCode = Message->Code;
  1317.  
  1318.                      GT_ReplyIMsg ((struct IntuiMessage *) Message);
  1319.               }
  1320.  
  1321.               switch (MyClass)
  1322.               {
  1323.                      case IDCMP_REFRESHWINDOW : GT_BeginRefresh (GadWin);
  1324.  
  1325.                                                 GT_EndRefresh (GadWin,TRUE);
  1326.  
  1327.                                                 break;
  1328.  
  1329.                      case IDCMP_VANILLAKEY    : switch (ToUpper (MyCode))
  1330.                                                 {
  1331.                                                        case 'L' : ActivateGadget (StringGad_1,GadWin,0);
  1332.  
  1333.                                                                   break;
  1334.  
  1335.                                                        case 'T' : ActivateGadget (StringGad_2,GadWin,0);
  1336.  
  1337.                                                                   break;
  1338.  
  1339.                                                        case 'R' : ActivateGadget (StringGad_3,GadWin,0);
  1340.  
  1341.                                                                   break;
  1342.  
  1343.                                                        case 'B' : ActivateGadget (StringGad_4,GadWin,0);
  1344.  
  1345.                                                                   break;
  1346.  
  1347.                                                        case 'A' : Accept = TRUE;
  1348.  
  1349.                                                                   break;
  1350.  
  1351.                                                        case 'I' : Ratio = TRUE;
  1352.  
  1353.                                                                   break;
  1354.  
  1355.                                                        case 'S' : Reset = TRUE;
  1356.  
  1357.                                                                   break;
  1358.  
  1359.                                                        case 'C' : Exit = TRUE;
  1360.  
  1361.                                                                   break;
  1362.  
  1363.                                                        case 'K' : KeepReal = ! KeepReal;
  1364.  
  1365.                                                                   GT_SetGadgetAttrs (MyCheckBoxGad,GadWin,NULL,GTCB_Checked,KeepReal,TAG_END);
  1366.  
  1367.                                                                   break;
  1368.  
  1369.                                                     case VAN_ESC: Exit = TRUE;
  1370.                                                 }
  1371.  
  1372.                                                         break;
  1373.  
  1374.                      case IDCMP_GADGETUP      : switch (MyGad->GadgetID)
  1375.                                                 {
  1376.                                                        case ACCEPT:   Accept = TRUE;
  1377.  
  1378.                                                                       break;
  1379.  
  1380.                                                        case  RATIO:   Ratio = TRUE;
  1381.  
  1382.                                                                       break;
  1383.  
  1384.                                                        case  RESET:   Reset = TRUE;
  1385.  
  1386.                                                                       break;
  1387.  
  1388.                                                        case   KEEP:   KeepReal = ! KeepReal;
  1389.  
  1390.                                                                       break;
  1391.  
  1392.                                                        case CANCEL:   Exit = TRUE;
  1393.                                                 }
  1394.  
  1395.                                                 break;
  1396.  
  1397.                      case IDCMP_CLOSEWINDOW   : Exit = TRUE;
  1398.               }
  1399.  
  1400.               if (Accept)
  1401.               {
  1402.                  sscanf (((struct StringInfo *) StringGad_1->SpecialInfo)->Buffer,"%lf",&Tmp_RMIN);
  1403.  
  1404.                  sscanf (((struct StringInfo *) StringGad_2->SpecialInfo)->Buffer,"%lf",&Tmp_IMAX);
  1405.  
  1406.                  sscanf (((struct StringInfo *) StringGad_3->SpecialInfo)->Buffer,"%lf",&Tmp_RMAX);
  1407.  
  1408.                  sscanf (((struct StringInfo *) StringGad_4->SpecialInfo)->Buffer,"%lf",&Tmp_IMIN);
  1409.  
  1410.                  if ((Tmp_RMIN >= Tmp_RMAX) || (Tmp_IMIN >= Tmp_IMAX)) DisplayBeep (Win->WScreen);
  1411.  
  1412.                  else
  1413.                  {
  1414.                     NewLimits = Exit = TRUE;
  1415.  
  1416.                     SaveCoords ();
  1417.  
  1418.                     RMIN  = Tmp_RMIN;
  1419.  
  1420.                     IMAX  = Tmp_IMAX;
  1421.  
  1422.                     RMAX  = Tmp_RMAX;
  1423.  
  1424.                     IMIN  = Tmp_IMIN;
  1425.                  }
  1426.  
  1427.                  Accept = FALSE;
  1428.               }
  1429.  
  1430.               if (Ratio)
  1431.               {
  1432.                  AdjustRatio (&Tmp_RMIN,&Tmp_IMAX,&Tmp_RMAX,&Tmp_IMIN,Win->Width,Win->Height,KeepReal);
  1433.  
  1434.                  TEXTGAD.ng_Flags = PLACETEXT_LEFT;
  1435.  
  1436.                  sprintf (String,"%+2.80lf",Tmp_RMIN);
  1437.  
  1438.                  GT_SetGadgetAttrs (StringGad_1,GadWin,NULL,GTST_String,String,TAG_END);
  1439.  
  1440.                  sprintf (String,"%+2.80lf",Tmp_IMAX);
  1441.  
  1442.                  GT_SetGadgetAttrs (StringGad_2,GadWin,NULL,GTST_String,String,TAG_END);
  1443.  
  1444.                  sprintf (String,"%+2.80lf",Tmp_RMAX);
  1445.  
  1446.                  TEXTGAD.ng_Flags = PLACETEXT_RIGHT;
  1447.  
  1448.                  GT_SetGadgetAttrs (StringGad_3,GadWin,NULL,GTST_String,String,TAG_END);
  1449.  
  1450.                  sprintf (String,"%+2.80lf",Tmp_IMIN);
  1451.  
  1452.                  GT_SetGadgetAttrs (StringGad_4,GadWin,NULL,GTST_String,String,TAG_END);
  1453.  
  1454.                  Ratio = FALSE;
  1455.               }
  1456.  
  1457.               if (Reset)
  1458.               {
  1459.                  TEXTGAD.ng_Flags = PLACETEXT_LEFT;
  1460.  
  1461.                  sprintf (String,"%+2.80lf",DEF_RMIN);
  1462.  
  1463.                  GT_SetGadgetAttrs (StringGad_1,GadWin,NULL,GTST_String,String,TAG_END);
  1464.  
  1465.                  sprintf (String,"%+2.80lf",DEF_IMAX);
  1466.  
  1467.                  GT_SetGadgetAttrs (StringGad_2,GadWin,NULL,GTST_String,String,TAG_END);
  1468.  
  1469.                  TEXTGAD.ng_Flags = PLACETEXT_RIGHT;
  1470.  
  1471.                  sprintf (String,"%+2.80lf",DEF_RMAX);
  1472.  
  1473.                  GT_SetGadgetAttrs (StringGad_3,GadWin,NULL,GTST_String,String,TAG_END);
  1474.  
  1475.                  sprintf (String,"%+2.80lf",DEF_IMIN);
  1476.  
  1477.                  GT_SetGadgetAttrs (StringGad_4,GadWin,NULL,GTST_String,String,TAG_END);
  1478.  
  1479.                  Reset = FALSE;
  1480.               }
  1481.  
  1482.            } while (Exit == FALSE);
  1483.  
  1484.        CloseWindow (GadWin);
  1485.      }
  1486.  
  1487.      else Fail (WindowGadgetError,15L);
  1488.   }
  1489.  
  1490.   else Fail (GadgetError,15L);
  1491.  
  1492.   FreeGadgets (GadList);
  1493.  
  1494.   return NewLimits;
  1495. }
  1496.  
  1497. ULONG IntegerGad (struct Window *Win,TEXT *TitleWin,TEXT *TitleScr,TEXT *TxtString,ULONG Var)
  1498. {
  1499. struct IntuiMessage *Message;
  1500.  
  1501. struct Gadget *GadList = NULL , *MyIntGad , *MyButtonGad , *MyGad = NULL;
  1502.  
  1503. struct Window *GadWin;
  1504.  
  1505. BOOL Exit = FALSE;
  1506.  
  1507. UWORD MyCode = 0;
  1508.  
  1509. ULONG MyClass = NULL;
  1510.  
  1511.   TEXTGAD.ng_VisualInfo = BUTTONGAD.ng_VisualInfo = VINFO;
  1512.  
  1513.   MyButtonGad = CreateContext (&GadList);
  1514.  
  1515.   BUTTONGAD.ng_LeftEdge   = 20;
  1516.  
  1517.   BUTTONGAD.ng_TopEdge    = 40;
  1518.  
  1519.   BUTTONGAD.ng_Width      = 80;
  1520.  
  1521.   BUTTONGAD.ng_Height     = 20;
  1522.  
  1523.   BUTTONGAD.ng_GadgetText = "_Accept";
  1524.  
  1525.   BUTTONGAD.ng_GadgetID   = ACCEPT;
  1526.  
  1527.   MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1528.  
  1529.   BUTTONGAD.ng_LeftEdge  += (20 + BUTTONGAD.ng_Width);
  1530.  
  1531.   BUTTONGAD.ng_GadgetText = "_Cancel";
  1532.  
  1533.   BUTTONGAD.ng_GadgetID   = CANCEL;
  1534.  
  1535.   MyButtonGad = CreateGadget (BUTTON_KIND,MyButtonGad,&BUTTONGAD,GT_Underscore,'_',TAG_END);
  1536.  
  1537.   TEXTGAD.ng_LeftEdge     = 120;
  1538.  
  1539.   TEXTGAD.ng_TopEdge      = 10;
  1540.  
  1541.   TEXTGAD.ng_Width        = 60;
  1542.  
  1543.   TEXTGAD.ng_Height       = 14;
  1544.  
  1545.   TEXTGAD.ng_GadgetText   = TxtString;
  1546.  
  1547.   TEXTGAD.ng_Flags        = PLACETEXT_LEFT;
  1548.  
  1549.   MyIntGad = CreateGadget (INTEGER_KIND,MyButtonGad,&TEXTGAD,GTIN_Number,Var,GTIN_MaxChars,6,STRINGA_ReplaceMode,TRUE,GT_Underscore,'_',TAG_END);
  1550.  
  1551.   if (MyIntGad)
  1552.   {
  1553.      GadWin = OpenWindowTags (NULL,WA_Left,Win->LeftEdge + 10,
  1554.                                    WA_Top,Win->TopEdge + 15,
  1555.                                    WA_Width,220,
  1556.                                    WA_Height,80,
  1557.                                    WA_Title,TitleWin,
  1558.                                    WA_ScreenTitle,TitleScr,
  1559.                                    WA_CustomScreen,Win->WScreen,
  1560.                                    WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|INTEGERIDCMP|BUTTONIDCMP,
  1561.                                    WA_Flags,WFLG_ACTIVATE|WFLG_DRAGBAR|WFLG_SIMPLE_REFRESH|WFLG_GIMMEZEROZERO|WFLG_RMBTRAP,
  1562.                                    WA_Gadgets,GadList,
  1563.                                    TAG_END);
  1564.  
  1565.      if (GadWin)
  1566.      {
  1567.         GT_RefreshWindow (GadWin,NULL);
  1568.  
  1569.         do {  WaitPort (GadWin->UserPort);
  1570.  
  1571.               if (Message = (struct IntuiMessage *) GT_GetIMsg (GadWin->UserPort))
  1572.               {
  1573.                      MyGad = (struct Gadget *) Message->IAddress;
  1574.  
  1575.                      MyClass = Message->Class;
  1576.  
  1577.                      MyCode = Message->Code;
  1578.  
  1579.                      GT_ReplyIMsg ((struct IntuiMessage *) Message);
  1580.               }
  1581.  
  1582.               switch (MyClass)
  1583.               {
  1584.                      case IDCMP_REFRESHWINDOW : GT_BeginRefresh (GadWin);
  1585.  
  1586.                                                 GT_EndRefresh (GadWin,TRUE);
  1587.  
  1588.                                                 break;
  1589.  
  1590.                      case IDCMP_VANILLAKEY    : switch (ToUpper (MyCode))
  1591.                                                 {
  1592.                                                        case 'D' :
  1593.  
  1594.                                                        case 'I' : ActivateGadget (MyIntGad,GadWin,0);
  1595.  
  1596.                                                                   break;
  1597.  
  1598.                                                        case 'A' : Var = ((struct StringInfo *) MyIntGad->SpecialInfo)->LongInt;
  1599.  
  1600.                                                                   Exit = TRUE;
  1601.  
  1602.                                                                   break;
  1603.  
  1604.                                                        case 'C' : Exit = TRUE;
  1605.  
  1606.                                                                   break;
  1607.  
  1608.                                                     case VAN_ESC: Exit = TRUE;
  1609.                                                 }
  1610.  
  1611.                                                 break;
  1612.  
  1613.                      case IDCMP_GADGETUP      : switch (MyGad->GadgetID)
  1614.                                                 {
  1615.                                                         case ACCEPT  : Var = ((struct StringInfo *) MyIntGad->SpecialInfo)->LongInt;
  1616.  
  1617.                                                                        Exit = TRUE;
  1618.  
  1619.                                                                        break;
  1620.  
  1621.                                                         case CANCEL  : Exit = TRUE;
  1622.                                                 }
  1623.  
  1624.                                                 break;
  1625.  
  1626.                      case IDCMP_CLOSEWINDOW   : Exit = TRUE;
  1627.               }
  1628.  
  1629.            } while (Exit == FALSE);
  1630.  
  1631.         CloseWindow (GadWin);
  1632.      }
  1633.  
  1634.      else Fail (WindowError,15L);
  1635.   }
  1636.  
  1637.   else Fail (GadgetError,15L);
  1638.  
  1639.   FreeGadgets (GadList);
  1640.  
  1641.   return Var;
  1642. }
  1643.  
  1644. WORD Integer (WORD Iterazioni,long double Cre,long double Cim)
  1645. {
  1646.   return MandInt (Iterazioni,(LONG) (Cre * MAX_POT),(LONG) (Cim * MAX_POT));
  1647. }
  1648.  
  1649. WORD Real (WORD Iterazioni,long double Cre,long double Cim)
  1650. {
  1651. long double zr = Cre , zi = Cim , zr2 , zi2;
  1652.  
  1653.   while (1L)
  1654.   {
  1655.      zr2 = zr * zr;
  1656.  
  1657.      zi2 = zi * zi;
  1658.  
  1659.      if ((zr2 + zi2) > 4.0) break;
  1660.  
  1661.      --Iterazioni;
  1662.  
  1663.      if (Iterazioni == 0) break;
  1664.  
  1665.      zi *= zr;
  1666.  
  1667.      zr  = zr2 - zi2 + Cre;
  1668.  
  1669.      zi += zi + Cim;
  1670.   }
  1671.  
  1672.   return Iterazioni;
  1673. }
  1674.  
  1675. VOID VLine_R_EHB (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
  1676. {
  1677. REGISTER LONG y;
  1678.  
  1679. ULONG Color;
  1680.  
  1681.  CRE = RMIN + (((long double)  x) * INCREMREAL);
  1682.  
  1683.  CIM = IMAX - (((long double) b2) * INCREMIMAG);
  1684.  
  1685.  for (y = b2; y >= b1; y--)
  1686.  {
  1687.      Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
  1688.  
  1689.      if (Color)
  1690.      {
  1691.         Color %= 56L;
  1692.  
  1693.         Color += 4L;
  1694.  
  1695.         if (Color > 31L) Color += 4L;
  1696.      }
  1697.  
  1698.      SetAPen (Rp,Color);
  1699.  
  1700.      WritePixel (Rp,x,y);
  1701.  
  1702.      CIM += INCREMIMAG;
  1703.  }
  1704. }
  1705.  
  1706. VOID HLine_R_EHB (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
  1707. {
  1708. REGISTER LONG x;
  1709.  
  1710. ULONG Color;
  1711.  
  1712.  CRE = RMIN + (((long double) a1) * INCREMREAL);
  1713.  
  1714.  CIM = IMAX - (((long double)  y) * INCREMIMAG);
  1715.  
  1716.  for (x = a1; x <= a2; x++)
  1717.  {
  1718.      Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
  1719.  
  1720.      if (Color)
  1721.      {
  1722.         Color %= 56L;
  1723.  
  1724.         Color += 4L;
  1725.  
  1726.         if (Color > 31L) Color += 4L;
  1727.      }
  1728.  
  1729.      SetAPen (Rp,Color);
  1730.  
  1731.      WritePixel (Rp,x,y);
  1732.  
  1733.      CRE += INCREMREAL;
  1734.  }
  1735. }
  1736.  
  1737. VOID VLine_R (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
  1738. {
  1739. REGISTER LONG y;
  1740.  
  1741. ULONG Color;
  1742.  
  1743.  CRE = RMIN + (((long double)  x) * INCREMREAL);
  1744.  
  1745.  CIM = IMAX - (((long double) b2) * INCREMIMAG);
  1746.  
  1747.  for (y = b2; y >= b1; y--)
  1748.  {
  1749.      Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
  1750.  
  1751.      if (Color)
  1752.      {
  1753.         Color %= COLOR_PENS;
  1754.  
  1755.         Color += 4L;
  1756.      }
  1757.  
  1758.      SetAPen (Rp,Color);
  1759.  
  1760.      WritePixel (Rp,x,y);
  1761.  
  1762.      CIM += INCREMIMAG;
  1763.  }
  1764. }
  1765.  
  1766. VOID HLine_R (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
  1767. {
  1768. REGISTER LONG x;
  1769.  
  1770. ULONG Color;
  1771.  
  1772.  CRE = RMIN + (((long double) a1) * INCREMREAL);
  1773.  
  1774.  CIM = IMAX - (((long double)  y) * INCREMIMAG);
  1775.  
  1776.  for (x = a1; x <= a2; x++)
  1777.  {
  1778.      Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
  1779.  
  1780.      if (Color)
  1781.      {
  1782.         Color %= COLOR_PENS;
  1783.  
  1784.         Color += 4L;
  1785.      }
  1786.  
  1787.      SetAPen (Rp,Color);
  1788.  
  1789.      WritePixel (Rp,x,y);
  1790.  
  1791.      CRE += INCREMREAL;
  1792.  }
  1793. }
  1794.  
  1795. VOID VLine_S_EHB (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
  1796. {
  1797. REGISTER LONG y;
  1798.  
  1799. ULONG Color;
  1800.  
  1801.  CRE = RMIN + (((long double)  x) * INCREMREAL);
  1802.  
  1803.  CIM = IMAX - (((long double) b2) * INCREMIMAG);
  1804.  
  1805.  for (y = b2; y >= b1; y--)
  1806.  {
  1807.      Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
  1808.  
  1809.      if (Color)
  1810.      {
  1811.         Color *= 56L;
  1812.  
  1813.         Color /= MAX_ITERATIONS_PLUS_ONE;
  1814.  
  1815.         Color += 4L;
  1816.  
  1817.         if (Color > 31L) Color += 4L;
  1818.      }
  1819.  
  1820.      SetAPen (Rp,Color);
  1821.  
  1822.      WritePixel (Rp,x,y);
  1823.  
  1824.      CIM += INCREMIMAG;
  1825.  }
  1826. }
  1827.  
  1828. VOID HLine_S_EHB (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
  1829. {
  1830. REGISTER LONG x;
  1831.  
  1832. ULONG Color;
  1833.  
  1834.  CRE = RMIN + (((long double) a1) * INCREMREAL);
  1835.  
  1836.  CIM = IMAX - (((long double)  y) * INCREMIMAG);
  1837.  
  1838.  for (x = a1; x <= a2; x++)
  1839.  {
  1840.      Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
  1841.  
  1842.      if (Color)
  1843.      {
  1844.         Color *= 56L;
  1845.  
  1846.         Color /= MAX_ITERATIONS_PLUS_ONE;
  1847.  
  1848.         Color += 4L;
  1849.  
  1850.         if (Color > 31L) Color += 4L;
  1851.      }
  1852.  
  1853.      SetAPen (Rp,Color);
  1854.  
  1855.      WritePixel (Rp,x,y);
  1856.  
  1857.      CRE += INCREMREAL;
  1858.  }
  1859. }
  1860.  
  1861. VOID VLine_S (struct RastPort *Rp,const LONG b1,const LONG b2,const LONG x)
  1862. {
  1863. REGISTER LONG y;
  1864.  
  1865. ULONG Color;
  1866.  
  1867.  CRE = RMIN + (((long double)  x) * INCREMREAL);
  1868.  
  1869.  CIM = IMAX - (((long double) b2) * INCREMIMAG);
  1870.  
  1871.  for (y = b2; y >= b1; y--)
  1872.  {
  1873.      Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
  1874.  
  1875.      if (Color)
  1876.      {
  1877.         Color *= COLOR_PENS;
  1878.  
  1879.         Color /= MAX_ITERATIONS_PLUS_ONE;
  1880.  
  1881.         Color += 4L;
  1882.      }
  1883.  
  1884.      SetAPen (Rp,Color);
  1885.  
  1886.      WritePixel (Rp,x,y);
  1887.  
  1888.      CIM += INCREMIMAG;
  1889.  }
  1890. }
  1891.  
  1892. VOID HLine_S (struct RastPort *Rp,const LONG a1,const LONG a2,const LONG y)
  1893. {
  1894. REGISTER LONG x;
  1895.  
  1896. ULONG Color;
  1897.  
  1898.  CRE = RMIN + (((long double) a1) * INCREMREAL);
  1899.  
  1900.  CIM = IMAX - (((long double)  y) * INCREMIMAG);
  1901.  
  1902.  for (x = a1; x <= a2; x++)
  1903.  {
  1904.      Color = FUNCTION (MAX_ITERATIONS,CRE,CIM);
  1905.  
  1906.      if (Color)
  1907.      {
  1908.         Color *= COLOR_PENS;
  1909.  
  1910.         Color /= MAX_ITERATIONS_PLUS_ONE;
  1911.  
  1912.         Color += 4L;
  1913.      }
  1914.  
  1915.      SetAPen (Rp,Color);
  1916.  
  1917.      WritePixel (Rp,x,y);
  1918.  
  1919.      CRE += INCREMREAL;
  1920.  }
  1921. }
  1922.  
  1923. BOOL CheckBox (struct RastPort *Rp,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
  1924. {
  1925. const LONG Color = ReadPixel (Rp,a1,b1);
  1926.  
  1927. REGISTER LONG Var;
  1928.  
  1929.   if (Color != ReadPixel (Rp,a2,b2)) return FALSE;
  1930.  
  1931.   if (Color != ReadPixel (Rp,a2,b1)) return FALSE;
  1932.  
  1933.   if (Color != ReadPixel (Rp,a1,b2)) return FALSE;
  1934.  
  1935.   for (Var = (a1 + 1L); Var <= (a2 - 1L); Var++)
  1936.   {
  1937.       if (Color != ReadPixel (Rp,Var,b1)) return FALSE;
  1938.  
  1939.       if (Color != ReadPixel (Rp,Var,b2)) return FALSE;
  1940.   }
  1941.  
  1942.   for (Var = (b1 + 1L); Var <= (b2 - 1L); Var++)
  1943.   {
  1944.       if (Color != ReadPixel (Rp,a1,Var)) return FALSE;
  1945.  
  1946.       if (Color != ReadPixel (Rp,a2,Var)) return FALSE;
  1947.   }
  1948.  
  1949.   return TRUE;
  1950. }
  1951.  
  1952. BOOL Rectangle (struct Window *Win,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
  1953. {
  1954. struct IntuiMessage *Message;
  1955.  
  1956. UWORD MyCode;
  1957.  
  1958. LONG helpx,helpy;
  1959.  
  1960. ULONG MyClass;
  1961.  
  1962.  if (Win->UserPort->mp_SigBit)
  1963.  {
  1964.     if (Message = (struct IntuiMessage *) GT_GetIMsg (Win->UserPort))
  1965.     {
  1966.        MyClass = Message->Class;
  1967.  
  1968.        MyCode  = Message->Code;
  1969.  
  1970.        GT_ReplyIMsg ((struct IntuiMessage *) Message);
  1971.  
  1972.        switch (MyClass)
  1973.        {
  1974.          case IDCMP_MENUPICK    : if (MyCode != MENUNULL)
  1975.                                   {
  1976.                                      if (ProcessMenu (Win,MyCode) & STOP_MSG) return TRUE;
  1977.                                   }
  1978.  
  1979.                                   break;
  1980.  
  1981.          case IDCMP_RAWKEY      : if (MyCode == TAB) return FALSE;
  1982.  
  1983.                                   if (MyCode == RAW_ESC) return TRUE;
  1984.  
  1985.                                   break;
  1986.  
  1987.          case IDCMP_CLOSEWINDOW : return TRUE;
  1988.        }
  1989.     }
  1990.  }
  1991.  
  1992.  helpx = a2 - a1;
  1993.  
  1994.  helpy = b2 - b1;
  1995.  
  1996.  if ((helpx < MINLIMIT) || (helpy < MINLIMIT)) return FALSE;
  1997.  
  1998.  if (CheckBox (Win->RPort,a1,b1,a2,b2))
  1999.  {
  2000.     SetAPen (Win->RPort,ReadPixel (Win->RPort,a1,b1));
  2001.  
  2002.     RectFill (Win->RPort,a1,b1,a2,b2);
  2003.  
  2004.     return FALSE;
  2005.  }
  2006.  
  2007.  if ((helpx < (MINLIMIT << 1L)) || (helpy < (MINLIMIT << 1L)))
  2008.  {
  2009.     for (helpy = (b1 + 1L); helpy <= (b2 - 1L); helpy++)
  2010.     {
  2011.         H_LINE (Win->RPort,a1+1L,a2-1L,helpy);
  2012.     }
  2013.  
  2014.     return FALSE;
  2015.  }
  2016.  
  2017.  if (helpx >= helpy)
  2018.  {
  2019.     helpx = (a1 + a2) >> 1L;
  2020.  
  2021.     V_LINE (Win->RPort,b1+1L,b2-1L,helpx);
  2022.  
  2023.     if (Rectangle (Win,a1,b1,helpx,b2)) return TRUE;
  2024.  
  2025.     if (Rectangle (Win,helpx,b1,a2,b2)) return TRUE;
  2026.  }
  2027.  
  2028.  else
  2029.  {
  2030.     helpy = (b1 + b2) >> 1L;
  2031.  
  2032.     H_LINE (Win->RPort,a1+1L,a2-1L,helpy);
  2033.  
  2034.     if (Rectangle (Win,a1,b1,a2,helpy)) return TRUE;
  2035.  
  2036.     if (Rectangle (Win,a1,helpy,a2,b2)) return TRUE;
  2037.  }
  2038.  
  2039.  return FALSE;
  2040. }
  2041.  
  2042. ULONG DrawFractal (struct Window *Win,const LONG a1,const LONG b1,const LONG a2,const LONG b2)
  2043. {
  2044. ULONG StartSec = NULL , EndSec = NULL , Dummy = NULL;
  2045.  
  2046.  CurrentTime (&StartSec,&Dummy);
  2047.  
  2048.  INCREMREAL = (fabs (RMAX-RMIN)) / ((long double) (a2 - a1 + 1L));
  2049.  
  2050.  INCREMIMAG = (fabs (IMAX-IMIN)) / ((long double) (b2 - b1 + 1L));
  2051.  
  2052.  MAX_ITERATIONS_PLUS_ONE = MAX_ITERATIONS + 1;
  2053.  
  2054.  if (TMASK & MASK) ShowTitle (Win->WScreen,FALSE);
  2055.  
  2056.  H_LINE (Win->RPort,a1,a2,b1);
  2057.  
  2058.  V_LINE (Win->RPort,b1+1L,b2-1L,a2);
  2059.  
  2060.  H_LINE (Win->RPort,a1,a2,b2);
  2061.  
  2062.  V_LINE (Win->RPort,b1+1L,b2-1L,a1);
  2063.  
  2064.  Rectangle (Win,a1,b1,a2,b2);
  2065.  
  2066.  if (TMASK & MASK) ShowTitle (Win->WScreen,TRUE);
  2067.  
  2068.  CurrentTime (&EndSec,&Dummy);
  2069.  
  2070.  return (EndSec-StartSec);
  2071. }
  2072.  
  2073. BOOL Preview (struct Window *Win,const LONG Width,const LONG Height)
  2074. {
  2075. struct Window *PreviewWin;
  2076.  
  2077. struct IntuiMessage *Message;
  2078.  
  2079. BOOL Error = FALSE;
  2080.  
  2081. UWORD MyCode = 0;
  2082.  
  2083. ULONG MyClass = NULL;
  2084.  
  2085.  MYBITMAP = CopyBitMap (Win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
  2086.  
  2087.  PreviewWin = OpenWindowTags (0,WA_Left,Win->LeftEdge + 10,
  2088.                                 WA_Top,Win->TopEdge + 15,
  2089.                                 WA_Width,(WORD) (Width  >> 1L),
  2090.                                 WA_Height,(WORD) (Height >> 1L),
  2091.                                 WA_Title,"Preview window",
  2092.                                 WA_ScreenTitle,"¼ Window preview...",
  2093.                                 WA_CustomScreen,Win->WScreen,
  2094.                                 WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW,
  2095.                                 WA_Flags,WFLG_ACTIVATE|WFLG_CLOSEGADGET|WFLG_DRAGBAR|WFLG_NOCAREREFRESH|WFLG_SMART_REFRESH|WFLG_RMBTRAP|WFLG_GIMMEZEROZERO,
  2096.                                 TAG_END);
  2097.  if (PreviewWin)
  2098.  {
  2099.     PasteWin (MYBITMAP,PreviewWin,ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
  2100.  
  2101.     PutPointer (PreviewWin,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  2102.  
  2103.     ELAPSEDTIME = DrawFractal (PreviewWin,0L,0L,(LONG) (PreviewWin->GZZWidth) - 1L,(LONG) (PreviewWin->GZZHeight) - 1L);
  2104.  
  2105.     PutPointer (PreviewWin,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  2106.  
  2107.     ShowTime (Win,"Preview elapsed time:",ELAPSEDTIME);
  2108.  
  2109.     while (1L)
  2110.     {
  2111.          WaitPort (PreviewWin->UserPort);
  2112.  
  2113.          if (Message = (struct IntuiMessage *) GT_GetIMsg (PreviewWin->UserPort))
  2114.          {
  2115.                 MyClass = Message->Class;
  2116.  
  2117.                 MyCode  = Message->Code;
  2118.  
  2119.                 GT_ReplyIMsg ((struct IntuiMessage *) Message);
  2120.          }
  2121.  
  2122.          if (MyClass == IDCMP_CLOSEWINDOW) break;
  2123.  
  2124.          if ((MyClass == IDCMP_RAWKEY) && (MyCode == RAW_ESC)) break;
  2125.     }
  2126.  
  2127.     PutPointer (PreviewWin,0,0,0,0,0,0);
  2128.  
  2129.     CloseWindow (PreviewWin);
  2130.  }
  2131.  
  2132.  else
  2133.  {
  2134.     if (BMASK & MASK)
  2135.     {
  2136.        FreeBitMap (MYBITMAP);
  2137.  
  2138.        MASK ^= BMASK;
  2139.     }
  2140.  
  2141.     Fail (PreviewWindowError,15L);
  2142.  
  2143.     Error = TRUE;
  2144.  }
  2145.  
  2146.  return Error;
  2147. }
  2148.  
  2149. BOOL DrawFrame (struct Window *Win,WORD Zx,WORD Zy,WORD Zw,WORD Zh)
  2150. {
  2151. WORD LeftEdge,TopEdge,RightEdge,BottomEdge;
  2152.  
  2153.   if ((Zx > 2) && (Zy > 2) && (Zx < Win->Width - 2) && (Zy < Win->Height - 2) && ((Zw >= INITIALZOOM) || (Zh >= INITIALZOOM)))
  2154.   {
  2155.      LeftEdge   = Zx - Zw;
  2156.  
  2157.      TopEdge    = Zy - Zh;
  2158.  
  2159.      RightEdge  = Zx + Zw;
  2160.  
  2161.      BottomEdge = Zy + Zh;
  2162.  
  2163.      if ((LeftEdge >= 0) && (TopEdge >= 0) && (RightEdge <= Win->Width) && (BottomEdge <= Win->Height))
  2164.      {
  2165.         ZOOMLINE [8] = ZOOMLINE [0] = ZOOMLINE [6] = LeftEdge;
  2166.  
  2167.         ZOOMLINE [1] = ZOOMLINE [3] = TopEdge;
  2168.  
  2169.         ZOOMLINE [2] = ZOOMLINE [4] = RightEdge;
  2170.  
  2171.         ZOOMLINE [5] = ZOOMLINE [7] = BottomEdge;
  2172.  
  2173.         ZOOMLINE [9] = ZOOMLINE [1] + 1;
  2174.      }
  2175.  
  2176.      DrawBorder (Win->RPort,&MYBORDER,0,0);
  2177.  
  2178.      MASK |= ZMASK;
  2179.   }
  2180.  
  2181.   else MASK ^= ZMASK;
  2182.  
  2183.   return (BOOL) (ZMASK & MASK);
  2184. }
  2185.  
  2186. BOOL FileRequest (struct Window *Win,TEXT *String,BOOL Mode,BOOL Type)
  2187. {
  2188. struct FileRequester *MyFileReq;
  2189.  
  2190. BOOL Success = FALSE;
  2191.  
  2192.  if (MyFileReq = AllocAslRequest (ASL_FileRequest,0))
  2193.  {
  2194.     if (Mode) strcpy (MYDIR,"PROGDIR:Pictures");
  2195.  
  2196.     else strcpy (MYDIR,"PROGDIR:Palettes");
  2197.  
  2198.     if (AslRequestTags (MyFileReq,ASLFR_Window,Win,
  2199.                                   ASLFR_InitialLeftEdge,Win->LeftEdge + 15,
  2200.                                   ASLFR_InitialTopEdge,Win->TopEdge + 25,
  2201.                                   ASLFR_InitialWidth,300,
  2202.                                   ASLFR_InitialHeight,((Win->Height) * 7) >> 3,
  2203.                                   ASLFR_SleepWindow,TRUE,
  2204.                                   ASLFR_TextAttr,&MYFONTSTRUCT,
  2205.                                   ASLFR_TitleText,String,
  2206.                                   ASLFR_InitialDrawer,MYDIR,
  2207.                                   ASLFR_InitialFile,MYFILE,
  2208.                                   ASLFR_DoSaveMode,Type,
  2209.                                   ASLFR_RejectIcons,TRUE,
  2210.                                   TAG_END))
  2211.     {
  2212.        strcpy (MYFILE,MyFileReq->rf_File);
  2213.  
  2214.        strcpy (MYDIR,MyFileReq->rf_Dir);
  2215.  
  2216.        strcpy (MYPATH,MYDIR);
  2217.  
  2218.        Success =  AddPart (MYPATH,MYFILE,sizeof (MYPATH));
  2219.     }
  2220.  
  2221.     FreeAslRequest (MyFileReq);
  2222.  }
  2223.  
  2224.  return Success;
  2225. }
  2226.  
  2227. BOOL FontRequest (struct Window *Win)
  2228. {
  2229. struct FontRequester *MyFontReq;
  2230.  
  2231. BOOL Success = FALSE;
  2232.  
  2233.  if (MyFontReq = AllocAslRequest (ASL_FontRequest,0))
  2234.  {
  2235.     if (AslRequestTags (MyFontReq,ASLFO_Window,Win,
  2236.                                   ASLFO_InitialLeftEdge,Win->LeftEdge + 15,
  2237.                                   ASLFO_InitialTopEdge,Win->TopEdge + 25,
  2238.                                   ASLFO_InitialWidth,300,
  2239.                                   ASLFO_InitialHeight,((Win->Height) * 7) >> 3,
  2240.                                   ASLFO_SleepWindow,TRUE,
  2241.                                   ASLFO_TextAttr,&MYFONTSTRUCT,
  2242.                                   ASLFO_TitleText,"Font requester",
  2243.                                   ASLFO_InitialName,MYFONTSTRUCT.ta_Name,
  2244.                                   ASLFO_InitialSize,MYFONTSTRUCT.ta_YSize,
  2245.                                   ASLFO_InitialStyle,MYFONTSTRUCT.ta_Style,
  2246.                                   ASLFO_InitialFlags,MYFONTSTRUCT.ta_Flags,
  2247.                                   ASLFO_DoFrontPen,TRUE,
  2248.                                   ASLFO_DoBackPen,TRUE,
  2249.                                   ASLFO_DoStyle,TRUE,
  2250.                                   ASLFO_DoDrawMode,TRUE,
  2251.                                   ASLFO_MinHeight,8,
  2252.                                   TAG_END))
  2253.     {
  2254.  
  2255.       strcpy (MYFONTSTRUCT.ta_Name,MyFontReq->fo_Attr.ta_Name);
  2256.  
  2257.       MYFONTSTRUCT.ta_YSize = MyFontReq->fo_Attr.ta_YSize;
  2258.  
  2259.       MYFONTSTRUCT.ta_Style = MyFontReq->fo_Attr.ta_Style;
  2260.  
  2261.       MYFONTSTRUCT.ta_Flags = MyFontReq->fo_Attr.ta_Flags;
  2262.  
  2263.       Success = TRUE;
  2264.     }
  2265.  
  2266.     FreeAslRequest (MyFontReq);
  2267.  }
  2268.  
  2269.  return Success;
  2270. }
  2271.  
  2272. BOOL SMRequest (struct ILBMInfo *Ilbm)
  2273. {
  2274. struct ScreenModeRequester *SMReq;
  2275.  
  2276. struct Window *Win = Ilbm->win;
  2277.  
  2278. BOOL NewScreen = FALSE;
  2279.  
  2280.  if (SMReq = AllocAslRequest (ASL_ScreenModeRequest,NULL))
  2281.  {
  2282.     if (AslRequestTags (SMReq,ASLSM_Window,Win,
  2283.                               ASLSM_SleepWindow,TRUE,
  2284.                               ASLSM_TitleText,"ScreenMode requester",
  2285.                               ASLSM_InitialLeftEdge,Win->LeftEdge + 15,
  2286.                               ASLSM_InitialTopEdge,Win->TopEdge + 25,
  2287.                               ASLSM_InitialWidth,310,
  2288.                               ASLSM_InitialHeight,((Win->Height) * 7) >> 3,
  2289.                               ASLSM_InitialDisplayID,GetVPModeID (ViewPortAddress (Win)),
  2290.                               ASLSM_InitialDisplayWidth,Win->Width,
  2291.                               ASLSM_InitialDisplayHeight,Win->Height,
  2292.                               ASLSM_InitialDisplayDepth,Win->RPort->BitMap->Depth,
  2293.                               ASLSM_InitialOverscanType,Ilbm->ucliptype,
  2294.                               ASLSM_DoWidth,TRUE,
  2295.                               ASLSM_DoHeight,TRUE,
  2296.                               ASLSM_DoDepth,TRUE,
  2297.                               ASLSM_DoOverscanType,TRUE,
  2298.                               ASLSM_MinDepth,MIN_DEPTH,
  2299.                               ASLSM_MaxDepth,MAX_DEPTH,
  2300.                               ASLSM_PropertyFlags,DIPF_IS_WB|DIPF_IS_EXTRAHALFBRITE,
  2301.                               ASLSM_PropertyMask,DIPF_IS_DUALPF|DIPF_IS_PF2PRI|DIPF_IS_HAM,
  2302.                               ASLSM_MinWidth,MIN_WIDTH,
  2303.                               ASLSM_MinHeight,MIN_HEIGHT,
  2304.                               TAG_END))
  2305.     {
  2306.        Ilbm->camg = SMReq->sm_DisplayID;
  2307.  
  2308.        Ilbm->Bmhd.w = SMReq->sm_DisplayWidth;
  2309.  
  2310.        Ilbm->Bmhd.h = SMReq->sm_DisplayHeight;
  2311.  
  2312.        Ilbm->Bmhd.nPlanes = SMReq->sm_DisplayDepth;
  2313.  
  2314.        Ilbm->ucliptype = SMReq->sm_OverscanType;
  2315.  
  2316.        NewScreen = TRUE;
  2317.     }
  2318.  
  2319.     FreeAslRequest (SMReq);
  2320.  }
  2321.  
  2322.  return NewScreen;
  2323. }
  2324.  
  2325. VOID SetMenuStart (struct Window *Win)
  2326. {
  2327.   OnMenu  (Win,FULLMENUNUM (0,0,NOSUB));
  2328.  
  2329.   OnMenu  (Win,FULLMENUNUM (0,2,NOSUB));
  2330.  
  2331.   OnMenu  (Win,FULLMENUNUM (0,3,NOSUB));
  2332.  
  2333.   OnMenu  (Win,FULLMENUNUM (0,4,NOSUB));
  2334.  
  2335.   OnMenu  (Win,FULLMENUNUM (0,5,NOSUB));
  2336.  
  2337.   OnMenu  (Win,FULLMENUNUM (0,7,NOSUB));
  2338.  
  2339.   OnMenu  (Win,FULLMENUNUM (0,9,NOSUB));
  2340.  
  2341.   OnMenu  (Win,FULLMENUNUM (1,0,NOSUB));
  2342.  
  2343.   OnMenu  (Win,FULLMENUNUM (1,1,NOSUB));
  2344.  
  2345.   OnMenu  (Win,FULLMENUNUM (1,2,NOSUB));
  2346.  
  2347.   OnMenu  (Win,FULLMENUNUM (1,4,NOSUB));
  2348.  
  2349.   OnMenu  (Win,FULLMENUNUM (2,2,NOSUB));
  2350.  
  2351.   OnMenu  (Win,FULLMENUNUM (2,4,NOSUB));
  2352.  
  2353.   OffMenu (Win,FULLMENUNUM (2,7,NOSUB));
  2354.  
  2355.   OnMenu (Win,FULLMENUNUM (3,0,NOSUB));
  2356.  
  2357.   OnMenu (Win,FULLMENUNUM (3,2,NOSUB));
  2358.  
  2359.   OnMenu (Win,FULLMENUNUM (3,4,NOSUB));
  2360.  
  2361.   OnMenu (Win,FULLMENUNUM (3,6,NOSUB));
  2362. }
  2363.  
  2364. VOID SetMenuStop (struct Window *Win)
  2365. {
  2366.   OffMenu  (Win,FULLMENUNUM (0,0,NOSUB));
  2367.  
  2368.   OffMenu  (Win,FULLMENUNUM (0,2,NOSUB));
  2369.  
  2370.   OffMenu  (Win,FULLMENUNUM (0,3,NOSUB));
  2371.  
  2372.   OffMenu  (Win,FULLMENUNUM (0,4,NOSUB));
  2373.  
  2374.   OffMenu  (Win,FULLMENUNUM (0,5,NOSUB));
  2375.  
  2376.   OffMenu  (Win,FULLMENUNUM (0,7,NOSUB));
  2377.  
  2378.   OffMenu  (Win,FULLMENUNUM (0,9,NOSUB));
  2379.  
  2380.   OffMenu  (Win,FULLMENUNUM (1,0,NOSUB));
  2381.  
  2382.   OffMenu  (Win,FULLMENUNUM (1,1,NOSUB));
  2383.  
  2384.   OffMenu  (Win,FULLMENUNUM (1,2,NOSUB));
  2385.  
  2386.   OffMenu  (Win,FULLMENUNUM (1,4,NOSUB));
  2387.  
  2388.   OffMenu  (Win,FULLMENUNUM (2,0,NOSUB));
  2389.  
  2390.   OffMenu  (Win,FULLMENUNUM (2,2,NOSUB));
  2391.  
  2392.   OffMenu  (Win,FULLMENUNUM (2,4,NOSUB));
  2393.  
  2394.   OffMenu  (Win,FULLMENUNUM (2,6,NOSUB));
  2395.  
  2396.   OnMenu   (Win,FULLMENUNUM (2,7,NOSUB));
  2397.  
  2398.   OffMenu (Win,FULLMENUNUM (3,0,NOSUB));
  2399.  
  2400.   OffMenu (Win,FULLMENUNUM (3,2,NOSUB));
  2401.  
  2402.   OffMenu (Win,FULLMENUNUM (3,4,NOSUB));
  2403.  
  2404.   OffMenu (Win,FULLMENUNUM (3,6,NOSUB));
  2405. }
  2406.  
  2407. ULONG ProcessMenu (struct Window *Win,UWORD Code)
  2408. {
  2409. struct MenuItem *Item;
  2410.  
  2411. ULONG Choice = NULL;
  2412.  
  2413.  while (Code != MENUNULL)
  2414.  {
  2415.   Item = ItemAddress (MAINMENU,Code);
  2416.  
  2417.   switch (MENUNUM (Code))
  2418.   {
  2419.         case 0:    switch (ITEMNUM (Code))
  2420.                    {
  2421.                         case 0: Choice |= ABOUT_MSG;
  2422.  
  2423.                                 break;
  2424.  
  2425.                         case 2: Choice |= LOADPICTURE_MSG;
  2426.  
  2427.                                 break;
  2428.  
  2429.                         case 3: Choice |= SAVEPICTURE_MSG;
  2430.  
  2431.                                 break;
  2432.  
  2433.                         case 4: Choice |= LOADPALETTE_MSG;
  2434.  
  2435.                                 break;
  2436.  
  2437.                         case 5: Choice |= SAVEPALETTE_MSG;
  2438.  
  2439.                                 break;
  2440.  
  2441.                         case 7: Choice |= DUMP_MSG;
  2442.  
  2443.                                 break;
  2444.  
  2445.                         case 9: Choice |= EXIT_MSG;
  2446.  
  2447.                                 break;
  2448.                    }
  2449.  
  2450.                    break;
  2451.  
  2452.         case 1:    switch (ITEMNUM (Code))
  2453.                    {
  2454.                         case 0: switch (SUBNUM (Code))
  2455.                                 {
  2456.                                    case 0: Choice |= TITLE_MSG;
  2457.  
  2458.                                            break;
  2459.  
  2460.                                    case 2: Choice |= TIME_MSG;
  2461.  
  2462.                                            break;
  2463.                                 }
  2464.  
  2465.                                 break;
  2466.  
  2467.                         case 1: Choice |= COORDS_MSG;
  2468.  
  2469.                                 break;
  2470.  
  2471.                         case 2: switch (SUBNUM (Code))
  2472.                                 {
  2473.                                    case 0: MAX_ITERATIONS = 63;
  2474.  
  2475.                                            break;
  2476.  
  2477.                                    case 1: MAX_ITERATIONS = 127;
  2478.  
  2479.                                            break;
  2480.  
  2481.                                    case 2: MAX_ITERATIONS = 191;
  2482.  
  2483.                                            break;
  2484.  
  2485.                                    case 3: MAX_ITERATIONS = 255;
  2486.  
  2487.                                            break;
  2488.  
  2489.                                    case 4: MAX_ITERATIONS = 319;
  2490.  
  2491.                                            break;
  2492.  
  2493.                                    case 5: MAX_ITERATIONS = 383;
  2494.  
  2495.                                            break;
  2496.  
  2497.                                    case 6: MAX_ITERATIONS = 447;
  2498.  
  2499.                                            break;
  2500.  
  2501.                                    case 7: MAX_ITERATIONS = 511;
  2502.  
  2503.                                            break;
  2504.  
  2505.                                    case 8: MAX_ITERATIONS = 1023;
  2506.  
  2507.                                            break;
  2508.  
  2509.                                   case 10: Choice |= ITER_MSG;
  2510.  
  2511.                                            break;
  2512.                                 }
  2513.  
  2514.                                 break;
  2515.  
  2516.                         case 3: switch (SUBNUM (Code))
  2517.                                 {
  2518.                                    case  0: PRIORITY = -5;
  2519.  
  2520.                                             break;
  2521.  
  2522.                                    case  1: PRIORITY = -4;
  2523.  
  2524.                                             break;
  2525.  
  2526.                                    case  2: PRIORITY = -3;
  2527.  
  2528.                                             break;
  2529.  
  2530.                                    case  3: PRIORITY = -2;
  2531.  
  2532.                                             break;
  2533.  
  2534.                                    case  4: PRIORITY = -1;
  2535.  
  2536.                                             break;
  2537.  
  2538.                                    case  6: PRIORITY =  0;
  2539.  
  2540.                                             break;
  2541.  
  2542.                                    case  8: PRIORITY =  1;
  2543.  
  2544.                                             break;
  2545.  
  2546.                                    case  9: PRIORITY =  2;
  2547.  
  2548.                                             break;
  2549.  
  2550.                                    case 10: PRIORITY =  3;
  2551.  
  2552.                                             break;
  2553.  
  2554.                                    case 11: PRIORITY =  4;
  2555.  
  2556.                                             break;
  2557.  
  2558.                                    case 12: PRIORITY =  5;
  2559.  
  2560.                                             break;
  2561.  
  2562.                                 }
  2563.  
  2564.                                 Forbid ();
  2565.  
  2566.                                 THISTASK = FindTask (NULL);
  2567.  
  2568.                                 Permit ();
  2569.  
  2570.                                 SetTaskPri (THISTASK,PRIORITY);
  2571.  
  2572.                                 break;
  2573.  
  2574.                         case 4: switch (SUBNUM (Code))
  2575.                                 {
  2576.                                    case 0: if (CheckEHB (MYILBM.camg))
  2577.                                            {
  2578.                                               H_LINE = HLine_R_EHB;
  2579.  
  2580.                                               V_LINE = VLine_R_EHB;
  2581.                                            }
  2582.  
  2583.                                            else
  2584.                                            {
  2585.                                               H_LINE = HLine_R;
  2586.  
  2587.                                               V_LINE = VLine_R;
  2588.                                            }
  2589.  
  2590.                                            SPREAD = FALSE;
  2591.  
  2592.                                            break;
  2593.  
  2594.                                    case 1: if (CheckEHB (MYILBM.camg))
  2595.                                            {
  2596.                                               H_LINE = HLine_S_EHB;
  2597.  
  2598.                                               V_LINE = VLine_S_EHB;
  2599.                                            }
  2600.  
  2601.                                            else
  2602.                                            {
  2603.                                               H_LINE = HLine_S;
  2604.  
  2605.                                               V_LINE = VLine_S;
  2606.                                            }
  2607.  
  2608.                                            SPREAD = TRUE;
  2609.  
  2610.                                            break;
  2611.                                 }
  2612.  
  2613.                                 break;
  2614.  
  2615.                         case 5: switch (SUBNUM (Code))
  2616.                                 {
  2617.                                    case 0: FUNCTION = Integer;
  2618.  
  2619.                                            break;
  2620.  
  2621.                                    case 1: FUNCTION = Real;
  2622.  
  2623.                                            break;
  2624.                                 }
  2625.  
  2626.                                 break;
  2627.                    }
  2628.  
  2629.                    break;
  2630.  
  2631.         case 2: switch (ITEMNUM (Code))
  2632.                 {
  2633.                    case 0: Choice |= PREVIEW_MSG;
  2634.  
  2635.                            break;
  2636.  
  2637.                    case 2: Choice |= REDRAW_MSG;
  2638.  
  2639.                            break;
  2640.  
  2641.                    case 4: Choice |= UNDO_MSG;
  2642.  
  2643.                            break;
  2644.  
  2645.                    case 6: Choice |= DRAW_MSG;
  2646.  
  2647.                            break;
  2648.  
  2649.                    case 7: Choice |= STOP_MSG;
  2650.  
  2651.                            break;
  2652.                 }
  2653.  
  2654.                 break;
  2655.  
  2656.         case 3: switch (ITEMNUM (Code))
  2657.                 {
  2658.                    case 0: switch (SUBNUM (Code))
  2659.                            {
  2660.                               case 0: Choice |= CYCLERIGHT_MSG;
  2661.  
  2662.                                       break;
  2663.  
  2664.                               case 1: Choice |= CYCLELEFT_MSG;
  2665.  
  2666.                                       break;
  2667.  
  2668.                               case 3: Choice |= DELAY_MSG;
  2669.  
  2670.                                       break;
  2671.  
  2672.                            }
  2673.  
  2674.                            break;
  2675.  
  2676.                    case 2: Choice |= PALETTE_MSG;
  2677.  
  2678.                            break;
  2679.  
  2680.                    case 4: Choice |= NEWDISPLAY_MSG;
  2681.  
  2682.                            break;
  2683.  
  2684.                    case 6: Choice |= FONTREQ_MSG;
  2685.  
  2686.                            break;
  2687.                 }
  2688.   }
  2689.  
  2690.  Code = Item->NextSelect;
  2691.  }
  2692.  
  2693.  return Choice;
  2694. }
  2695.  
  2696. VOID ProcessMouse (struct Window *Win,WORD CurMouseX,WORD CurMouseY)
  2697. {
  2698. static WORD MX1 = 0 , MY1 = 0 , MX2 = 0 , MY2 = 0 , W = 0 , H = 0;
  2699.  
  2700. struct IntuiMessage *Message;
  2701.  
  2702. UWORD MyCode = 0,DefaultQueue;
  2703.  
  2704. ULONG MyClass = NULL;
  2705.  
  2706.    ModifyIDCMP (Win,IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE);
  2707.  
  2708.    DefaultQueue = SetMouseQueue (Win,10);
  2709.  
  2710.    if (ZMASK & MASK) DrawFrame (Win,MX1,MY1,W,H);
  2711.  
  2712.    MX1 = CurMouseX;
  2713.  
  2714.    MY1 = CurMouseY;
  2715.  
  2716.    W = INITIALZOOM;
  2717.  
  2718.    H = ScalerDiv (W,Win->Height,Win->Width);
  2719.  
  2720.    DrawFrame (Win,MX1,MY1,W,H);
  2721.  
  2722.    while (1L)
  2723.    {
  2724.      WaitPort (Win->UserPort);
  2725.  
  2726.      if (Message = (struct IntuiMessage *) GT_GetIMsg (Win->UserPort))
  2727.      {
  2728.             MyClass = Message->Class;
  2729.  
  2730.             MyCode = Message->Code;
  2731.  
  2732.             MX2 = Message->MouseX;
  2733.  
  2734.             MY2 = Message->MouseY;
  2735.  
  2736.             GT_ReplyIMsg ((struct IntuiMessage *) Message);
  2737.      }
  2738.  
  2739.      if (MyClass == IDCMP_MOUSEMOVE)
  2740.      {
  2741.          DrawFrame (Win,MX1,MY1,W,H);
  2742.  
  2743.          W = abs (MX1 - MX2);
  2744.  
  2745.          H = abs (MY1 - MY2);
  2746.  
  2747.          if (W > H) (W = ScalerDiv (H,Win->Width,Win->Height));
  2748.  
  2749.          else       (H = ScalerDiv (W,Win->Height,Win->Width));
  2750.  
  2751.          DrawFrame (Win,MX1,MY1,W,H);
  2752.      }
  2753.  
  2754.      else if ((MyClass == IDCMP_MOUSEBUTTONS) && (MyCode != SELECTDOWN)) break;
  2755.    }
  2756.  
  2757.    SetMouseQueue (Win,DefaultQueue);
  2758.  
  2759.    ModifyIDCMP (Win,IDCMP_STANDARD);
  2760.  
  2761.    if (ZMASK & MASK)
  2762.    {
  2763.       OnMenu  (Win,FULLMENUNUM (2,0,NOSUB));
  2764.  
  2765.       OnMenu  (Win,FULLMENUNUM (2,6,NOSUB));
  2766.    }
  2767.  
  2768.    else
  2769.    {
  2770.       OffMenu  (Win,FULLMENUNUM (2,0,NOSUB));
  2771.  
  2772.       OffMenu  (Win,FULLMENUNUM (2,6,NOSUB));
  2773.    }
  2774. }
  2775.  
  2776. ULONG HandleEvents (struct ILBMInfo *Ilbm)
  2777. {
  2778. struct IntuiMessage *Message;
  2779.  
  2780. WORD MouseX = 0,MouseY = 0;
  2781.  
  2782. UWORD MyCode = 0,Index;
  2783.  
  2784. LONG Error;
  2785.  
  2786. ULONG MyClass = NULL,MyMenu = NULL;
  2787.  
  2788. double RealCoord,ImagCoord,RealDist,ImagDist,Kre,Kim,ScrRatio,FracRatio;
  2789.  
  2790.  PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  2791.  
  2792.  RealDist = fabs (RMAX-RMIN);
  2793.  
  2794.  ImagDist = fabs (IMAX-IMIN);
  2795.  
  2796.  Kre = RealDist / (double) (Ilbm->win->Width - 1);
  2797.  
  2798.  Kim = ImagDist / (double) (Ilbm->win->Height - 1);
  2799.  
  2800.  ScrRatio = (double) Ilbm->win->Width / (double) Ilbm->win->Height;
  2801.  
  2802.  FracRatio = RealDist / ImagDist;
  2803.  
  2804.  do { WaitPort (Ilbm->win->UserPort);
  2805.  
  2806.       if (Message = (struct IntuiMessage *) GT_GetIMsg (Ilbm->win->UserPort))
  2807.       {
  2808.              MyClass = Message->Class;
  2809.  
  2810.              MyCode  = Message->Code;
  2811.  
  2812.              MouseX  = Message->MouseX;
  2813.  
  2814.              MouseY  = Message->MouseY;
  2815.  
  2816.              GT_ReplyIMsg ((struct IntuiMessage *) Message);
  2817.       }
  2818.  
  2819.       switch (MyClass)
  2820.       {
  2821.              case    IDCMP_MOUSEMOVE: if (TMASK & MASK)
  2822.                                       {
  2823.                                          RealCoord = RMIN + (double) MouseX * Kre;
  2824.  
  2825.                                          ImagCoord = IMAX - (double) MouseY * Kim;
  2826.  
  2827.                                          sprintf (BAR_STRING,"Real %+2.16lf Imag %+2.16lfi W:H %.5lf R:I %.5lf",RealCoord,ImagCoord,ScrRatio,FracRatio);
  2828.  
  2829.                                          WaitTOF ();
  2830.  
  2831.                                          SetWindowTitles (Ilbm->win,(TEXT *) ~0,BAR_STRING);
  2832.                                       }
  2833.  
  2834.                                       break;
  2835.  
  2836.              case IDCMP_MOUSEBUTTONS: if (MyCode == SELECTDOWN) ProcessMouse (Ilbm->win,MouseX,MouseY);
  2837.  
  2838.                                       break;
  2839.  
  2840.              case     IDCMP_MENUPICK: MyMenu = ProcessMenu (Ilbm->win,MyCode);
  2841.  
  2842.                                       if (MyMenu & EXIT_MSG) break;
  2843.  
  2844.                                       if (MyMenu & TITLE_MSG)
  2845.                                       {
  2846.                                          if (TMASK & MASK) MASK ^= TMASK;
  2847.  
  2848.                                          else MASK |= TMASK;
  2849.  
  2850.                                          Ilbm->TBState = TMASK & MASK;
  2851.  
  2852.                                          ShowTitle (Ilbm->scr,Ilbm->TBState);
  2853.  
  2854.                                          break;
  2855.                                       }
  2856.  
  2857.                                       if (MyMenu & TIME_MSG)
  2858.                                       {
  2859.                                          if (! (TMASK & MASK)) ShowTitle (Ilbm->scr,TRUE);
  2860.  
  2861.                                          ShowTime (Ilbm->win,"Last calculating time:",ELAPSEDTIME);
  2862.  
  2863.                                          Delay (MYSECS);
  2864.  
  2865.                                          if (! (TMASK & MASK)) ShowTitle (Ilbm->scr,FALSE);
  2866.  
  2867.                                          break;
  2868.                                       }
  2869.  
  2870.                                       if (MyMenu & ITER_MSG)
  2871.                                       {
  2872.                                          ModifyIDCMP (Ilbm->win,NULL);
  2873.  
  2874.                                          ClearMenuStrip (Ilbm->win);
  2875.  
  2876.                                          while (1L)
  2877.                                          {
  2878.                                             MAX_ITERATIONS = (WORD) IntegerGad (Ilbm->win,"Iterations requester","Insert new iterations...","_Iterations",MAX_ITERATIONS + 1L) - 1L;
  2879.  
  2880.                                             if (MAX_ITERATIONS >= 15L) break;
  2881.  
  2882.                                             DisplayBeep (Ilbm->scr);
  2883.                                          }
  2884.  
  2885.                                          ResetMenuStrip (Ilbm->win,MAINMENU);
  2886.  
  2887.                                          ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  2888.  
  2889.                                          break;
  2890.                                       }
  2891.  
  2892.                                       if (MyMenu & ABOUT_MSG)
  2893.                                       {
  2894.                                          ModifyIDCMP (Ilbm->win,NULL);
  2895.  
  2896.                                          ClearMenuStrip (Ilbm->win);
  2897.  
  2898.                                          About (Ilbm->win);
  2899.  
  2900.                                          ResetMenuStrip (Ilbm->win,MAINMENU);
  2901.  
  2902.                                          ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  2903.  
  2904.                                          break;
  2905.                                       }
  2906.  
  2907.                                       if (MyMenu & PALETTE_MSG)
  2908.                                       {
  2909.                                          ModifyIDCMP (Ilbm->win,NULL);
  2910.  
  2911.                                          ClearMenuStrip (Ilbm->win);
  2912.  
  2913.                                          if (! ModifyPalette (Ilbm->win,Ilbm->win->LeftEdge + 10,Ilbm->win->TopEdge + 15,300,185,PALETTE)) Fail (PaletteRequesterError,15L);
  2914.  
  2915.                                          ResetMenuStrip (Ilbm->win,MAINMENU);
  2916.  
  2917.                                          ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  2918.  
  2919.                                          break;
  2920.                                       }
  2921.  
  2922.                                       if (MyMenu & CYCLERIGHT_MSG)
  2923.                                       {
  2924.                                          ModifyIDCMP (Ilbm->win,IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY|IDCMP_MENUPICK);
  2925.  
  2926.                                          if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
  2927.  
  2928.                                          ClearMenuStrip (Ilbm->win);
  2929.  
  2930.                                          PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  2931.  
  2932.                                          Cycle (Ilbm->win,DELAY,SHIFTRIGHT);
  2933.  
  2934.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  2935.  
  2936.                                          ResetMenuStrip (Ilbm->win,MAINMENU);
  2937.  
  2938.                                          if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
  2939.  
  2940.                                          LoadRGB32 (ViewPortAddress (Ilbm->win),PALETTE);
  2941.  
  2942.                                          ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  2943.  
  2944.                                          break;
  2945.                                       }
  2946.  
  2947.                                       if (MyMenu & CYCLELEFT_MSG)
  2948.                                       {
  2949.                                          ModifyIDCMP (Ilbm->win,IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY|IDCMP_MENUPICK);
  2950.  
  2951.                                          if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
  2952.  
  2953.                                          ClearMenuStrip (Ilbm->win);
  2954.  
  2955.                                          PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  2956.  
  2957.                                          Cycle (Ilbm->win,DELAY,SHIFTLEFT);
  2958.  
  2959.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  2960.  
  2961.                                          ResetMenuStrip (Ilbm->win,MAINMENU);
  2962.  
  2963.                                          if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
  2964.  
  2965.                                          LoadRGB32 (ViewPortAddress (Ilbm->win),PALETTE);
  2966.  
  2967.                                          ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  2968.  
  2969.                                          break;
  2970.                                       }
  2971.  
  2972.                                       if (MyMenu & DELAY_MSG)
  2973.                                       {
  2974.                                          while (1L)
  2975.                                          {
  2976.                                             DELAY = IntegerGad (Ilbm->win,"Delay requester","Insert delay time...","_Delay time",DELAY);
  2977.  
  2978.                                             if (DELAY >= 0L) break;
  2979.  
  2980.                                             DisplayBeep (Ilbm->scr);
  2981.                                          }
  2982.  
  2983.                                          break;
  2984.                                       }
  2985.  
  2986.                                       if (MyMenu & STOP_MSG)
  2987.                                       {
  2988.                                          SetMenuStart (Ilbm->win);
  2989.  
  2990.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  2991.  
  2992.                                          break;
  2993.                                       }
  2994.  
  2995.                                       if (MyMenu & LOADPICTURE_MSG)
  2996.                                       {
  2997.                                          if (FileRequest (Ilbm->win,"Load iff picture",PICTURE_MODE,FALSE))
  2998.                                          {
  2999.                                             PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3000.  
  3001.                                             if (Ilbm->ParseInfo.iff = AllocIFF ())
  3002.                                             {
  3003.                                                if (! (Error = QueryMandPic (Ilbm,&MANDChunkTmp,MYPATH)))
  3004.                                                {
  3005.                                                   MANDChunk = *MANDChunkTmp;
  3006.                    
  3007.                                                   SaveCoords ();
  3008.  
  3009.                                                   RMIN = MANDChunk.RMin;
  3010.  
  3011.                                                   RMAX = MANDChunk.RMax;
  3012.  
  3013.                                                   IMIN = MANDChunk.IMin;
  3014.  
  3015.                                                   IMAX = MANDChunk.IMax;
  3016.  
  3017.                                                   MAX_ITERATIONS = MANDChunk.Iterations - 1L;
  3018.  
  3019.                                                   RealDist = fabs (RMAX-RMIN);
  3020.  
  3021.                                                   ImagDist = fabs (IMAX-IMIN);
  3022.  
  3023.                                                   Kre = RealDist / (double) (Ilbm->win->Width - 1);
  3024.  
  3025.                                                   Kim = ImagDist / (double) (Ilbm->win->Height - 1);
  3026.  
  3027.                                                   FracRatio = RealDist / ImagDist;
  3028.  
  3029.                                                   if (MANDChunk.Special & SPREAD_BIT) SPREAD = TRUE;
  3030.  
  3031.                                                   else SPREAD = FALSE;
  3032.  
  3033.                                                   if (MANDChunk.Special & INTEGER_BIT) FUNCTION = Integer;
  3034.  
  3035.                                                   else FUNCTION = Real;
  3036.  
  3037.                                                   CloseDisplay (Ilbm,VINFO);
  3038.  
  3039.                                                   Ilbm->IFFPFlags = IFFPF_BESTFIT;
  3040.  
  3041.                                                   COLOR_PENS = MakeDisplay (Ilbm);
  3042.  
  3043.                                                   Ilbm->IFFPFlags = NULL;
  3044.  
  3045.                                                   if (! COLOR_PENS)
  3046.                                                   {
  3047.                                                      Fail (MakeDisplayError,20L);
  3048.  
  3049.                                                      MyMenu = EXIT_MSG;
  3050.  
  3051.                                                      break;
  3052.                                                   }
  3053.  
  3054.                                                   if (ZMASK & MASK) MASK ^= ZMASK;
  3055.  
  3056.                                                   COLOR_PENS -= 4L;
  3057.  
  3058.                                                   if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
  3059.  
  3060.                                                   if (LoadMandPic (Ilbm,MYPATH)) Fail (LoadMandPicError,5L);
  3061.  
  3062.                                                   if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
  3063.  
  3064.                                                   if (CheckEHB (Ilbm->camg)) GetRGB32 (Ilbm->vp->ColorMap,0L,32L,&PALETTE [1L]);
  3065.  
  3066.                                                   else GetRGB32 (Ilbm->vp->ColorMap,0L,Ilbm->vp->ColorMap->Count,&PALETTE [1L]);
  3067.  
  3068.                                                   LoadRGB32 (Ilbm->vp,PALETTE);
  3069.  
  3070.                                                   ClearMenuStrip (Ilbm->win);
  3071.  
  3072.                                                   if (SPREAD)
  3073.                                                   {
  3074.                                                      if (ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags ^= CHECKED;
  3075.  
  3076.                                                      if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags |= CHECKED;
  3077.  
  3078.                                                      if (CheckEHB (MYILBM.camg))
  3079.                                                      {
  3080.                                                         H_LINE = HLine_S_EHB;
  3081.  
  3082.                                                         V_LINE = VLine_S_EHB;
  3083.                                                      }
  3084.  
  3085.                                                      else
  3086.                                                      {
  3087.                                                         H_LINE = HLine_S;
  3088.  
  3089.                                                         V_LINE = VLine_S;
  3090.                                                      }
  3091.                                                   }
  3092.  
  3093.                                                   else
  3094.                                                   {
  3095.                                                      if (ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,4,1))->Flags ^= CHECKED;
  3096.  
  3097.                                                      if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,4,0))->Flags |= CHECKED;
  3098.  
  3099.                                                      if (CheckEHB (MYILBM.camg))
  3100.                                                      {
  3101.                                                         H_LINE = HLine_R_EHB;
  3102.  
  3103.                                                         V_LINE = VLine_R_EHB;
  3104.                                                      }
  3105.  
  3106.                                                      else
  3107.                                                      {
  3108.                                                         H_LINE = HLine_R;
  3109.  
  3110.                                                         V_LINE = VLine_R;
  3111.                                                      }
  3112.                                                   }
  3113.  
  3114.                                                   for (Index = 0; Index <= 10; Index++) if (ItemAddress (MAINMENU,FULLMENUNUM (1,2,Index))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,2,Index))->Flags ^= CHECKED;
  3115.  
  3116.                                                   switch (MAX_ITERATIONS)
  3117.                                                   {
  3118.                                                     case 63 :  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,0))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,0))->Flags |= CHECKED;
  3119.  
  3120.                                                                break;
  3121.  
  3122.                                                     case 127:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,1))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,1))->Flags |= CHECKED;
  3123.  
  3124.                                                                break;
  3125.  
  3126.                                                     case 191:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,2))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,2))->Flags |= CHECKED;
  3127.  
  3128.                                                                break;
  3129.  
  3130.                                                     case 255:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,3))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,3))->Flags |= CHECKED;
  3131.  
  3132.                                                                break;
  3133.  
  3134.                                                     case 319:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,4))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,4))->Flags |= CHECKED;
  3135.  
  3136.                                                                break;
  3137.  
  3138.                                                     case 383:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,5))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,5))->Flags |= CHECKED;
  3139.  
  3140.                                                                break;
  3141.  
  3142.                                                     case 447:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,6))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,6))->Flags |= CHECKED;
  3143.  
  3144.                                                                break;
  3145.  
  3146.                                                     case 511:  if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,7))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,7))->Flags |= CHECKED;
  3147.  
  3148.                                                                break;
  3149.  
  3150.                                                     case 1023: if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,8))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,8))->Flags |= CHECKED;
  3151.  
  3152.                                                                break;
  3153.  
  3154.                                                     default:   if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,2,10))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,2,10))->Flags |= CHECKED;
  3155.  
  3156.                                                                break;
  3157.                                                   }
  3158.  
  3159.                                                   if (FUNCTION == Integer)
  3160.                                                   {
  3161.                                                      if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags ^= CHECKED;
  3162.  
  3163.                                                      if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags |= CHECKED;
  3164.                                                   }
  3165.  
  3166.                                                   else
  3167.                                                   {
  3168.                                                      if (ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags & CHECKED) ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags ^= CHECKED;
  3169.  
  3170.                                                      if (! (ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags & CHECKED)) ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags |= CHECKED;
  3171.                                                   }
  3172.  
  3173.                                                   ResetMenuStrip (Ilbm->win,MAINMENU);
  3174.                                                }
  3175.  
  3176.                                                else Fail (QueryMandPicError,NULL);
  3177.  
  3178.                                                FreeIFF (Ilbm->ParseInfo.iff);
  3179.                                             }
  3180.                                          }
  3181.  
  3182.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3183.  
  3184.                                          break;
  3185.                                       }
  3186.  
  3187.                                       if (MyMenu & SAVEPICTURE_MSG)
  3188.                                       {
  3189.                                          if (FileRequest (Ilbm->win,"Save iff picture",PICTURE_MODE,TRUE))
  3190.                                          {
  3191.                                             PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3192.  
  3193.                                             if (Ilbm->ParseInfo.iff = AllocIFF ())
  3194.                                             {
  3195.                                                MANDChunk.LeftEdge = Ilbm->win->LeftEdge;
  3196.  
  3197.                                                MANDChunk.TopEdge = Ilbm->win->TopEdge;
  3198.  
  3199.                                                MANDChunk.Width = Ilbm->win->Width;
  3200.  
  3201.                                                MANDChunk.Height = Ilbm->win->Height;
  3202.  
  3203.                                                MANDChunk.RMin = RMIN;
  3204.  
  3205.                                                MANDChunk.RMax = RMAX;
  3206.  
  3207.                                                MANDChunk.IMin = IMIN;
  3208.  
  3209.                                                MANDChunk.IMax = IMAX;
  3210.  
  3211.                                                MANDChunk.Iterations = MAX_ITERATIONS + 1L;
  3212.  
  3213.                                                MANDChunk.Special = NULL;
  3214.  
  3215.                                                if (SPREAD) MANDChunk.Special |= SPREAD_BIT;
  3216.  
  3217.                                                if (FUNCTION == Integer) MANDChunk.Special |= INTEGER_BIT;
  3218.  
  3219.                                                if (ZMASK & MASK)
  3220.                                                {
  3221.                                                   DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3222.  
  3223.                                                   MASK ^= ZMASK;
  3224.                                                }
  3225.  
  3226.                                                if (TMASK & MASK) ShowTitle (Ilbm->scr,FALSE);
  3227.  
  3228.                                                if (SaveMandPic (Ilbm,&SPECIAL_CHUNK,©RIGHT_CHUNK,MYPATH)) Fail (SaveMandPicError,5L);
  3229.  
  3230.                                                if (TMASK & MASK) ShowTitle (Ilbm->scr,TRUE);
  3231.  
  3232.                                                FreeIFF (Ilbm->ParseInfo.iff);
  3233.                                             }
  3234.                                          }
  3235.  
  3236.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3237.  
  3238.                                          break;
  3239.                                       }
  3240.  
  3241.                                       if (MyMenu & LOADPALETTE_MSG)
  3242.                                       {
  3243.                                          if (FileRequest (Ilbm->win,"Load palette",PALETTE_MODE,FALSE))
  3244.                                          {
  3245.                                             PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3246.  
  3247.                                             if (Ilbm->ParseInfo.iff = AllocIFF ())
  3248.                                             {
  3249.                                                LoadPalette (Ilbm,MYPATH);
  3250.  
  3251.                                                if (CheckEHB (Ilbm->camg)) GetRGB32 (Ilbm->vp->ColorMap,0L,32L,&PALETTE [1L]);
  3252.  
  3253.                                                else GetRGB32 (Ilbm->vp->ColorMap,0L,Ilbm->vp->ColorMap->Count,&PALETTE [1L]);
  3254.  
  3255.                                                LoadRGB32 (Ilbm->vp,PALETTE);
  3256.  
  3257.                                                FreeIFF (Ilbm->ParseInfo.iff);
  3258.                                             }
  3259.                                          }
  3260.  
  3261.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3262.  
  3263.                                          break;
  3264.                                       }
  3265.  
  3266.                                       if (MyMenu & SAVEPALETTE_MSG)
  3267.                                       {
  3268.                                          if (FileRequest (Ilbm->win,"Save palette",PALETTE_MODE,TRUE))
  3269.                                          {
  3270.                                             PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3271.  
  3272.                                             if (Ilbm->ParseInfo.iff = AllocIFF ())
  3273.                                             {
  3274.                                                SavePalette (Ilbm,©RIGHT_CHUNK,MYPATH);
  3275.  
  3276.                                                FreeIFF (Ilbm->ParseInfo.iff);
  3277.                                             }
  3278.                                          }
  3279.  
  3280.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3281.  
  3282.                                          break;
  3283.                                       }
  3284.  
  3285.                                       if (MyMenu & FONTREQ_MSG)
  3286.                                       {
  3287.                                          if (FontRequest (Ilbm->win))
  3288.                                          {
  3289.                                             PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3290.  
  3291.                                             MYBITMAP = CopyBitMap (Ilbm->win,0,0,Ilbm->win->Width,Ilbm->win->Height);
  3292.  
  3293.                                             CloseDisplay (Ilbm,VINFO);
  3294.  
  3295.                                             if (NEWFONT = OpenDiskFont (&MYFONTSTRUCT)) MASK |= FMASK;
  3296.  
  3297.                                             else
  3298.                                             {
  3299.                                                strcpy (MYFONTSTRUCT.ta_Name,"topaz.font");
  3300.  
  3301.                                                MYFONTSTRUCT.ta_YSize = 8;
  3302.  
  3303.                                                MYFONTSTRUCT.ta_Style = FS_NORMAL;
  3304.  
  3305.                                                MYFONTSTRUCT.ta_Flags = FPF_ROMFONT;
  3306.                                             }
  3307.  
  3308.                                             MakeDisplay (Ilbm);
  3309.  
  3310.                                             PasteWin (MYBITMAP,Ilbm->win,Ilbm->win->Width,Ilbm->win->Height);
  3311.                                          }
  3312.  
  3313.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3314.  
  3315.                                          break;
  3316.                                       }
  3317.  
  3318.                                       if (MyMenu & DUMP_MSG)
  3319.                                       {
  3320.                                          ModifyIDCMP (Ilbm->win,NULL);
  3321.  
  3322.                                          ClearMenuStrip (Ilbm->win);
  3323.  
  3324.                                          PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3325.  
  3326.                                          if (Choice (Ilbm->win,"Print requester","Are you sure ?"))
  3327.                                          {
  3328.                                             WinDump (Ilbm->win);
  3329.                                          }
  3330.  
  3331.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3332.  
  3333.                                          ResetMenuStrip (Ilbm->win,MAINMENU);
  3334.  
  3335.                                          ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3336.  
  3337.                                          break;
  3338.                                       }
  3339.  
  3340.                                       if (MyMenu & PREVIEW_MSG)
  3341.                                       {
  3342.                                          if (NewCoords (Ilbm->win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4],ZOOMLINE [5]))
  3343.                                          {
  3344.                                             ModifyIDCMP (Ilbm->win,NULL);
  3345.  
  3346.                                             ClearMenuStrip (Ilbm->win);
  3347.  
  3348.                                             Preview (Ilbm->win,Ilbm->win->Width,Ilbm->win->Height);
  3349.  
  3350.                                             ResetMenuStrip (Ilbm->win,MAINMENU);
  3351.  
  3352.                                             ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3353.  
  3354.                                             RestoreCoords ();
  3355.                                          }
  3356.  
  3357.                                          break;
  3358.                                       }
  3359.  
  3360.                                       if (MyMenu & COORDS_MSG)
  3361.                                       {
  3362.                                          ModifyIDCMP (Ilbm->win,NULL);
  3363.  
  3364.                                          ClearMenuStrip (Ilbm->win);
  3365.  
  3366.                                          if (ShowCoords (Ilbm->win))
  3367.                                          {
  3368.                                             RealDist = fabs (RMAX-RMIN);
  3369.  
  3370.                                             ImagDist = fabs (IMAX-IMIN);
  3371.  
  3372.                                             Kre = RealDist / (double) (Ilbm->win->Width - 1);
  3373.  
  3374.                                             Kim = ImagDist / (double) (Ilbm->win->Height - 1);
  3375.  
  3376.                                             FracRatio = RealDist / ImagDist;
  3377.  
  3378.                                             if (Choice (Ilbm->win,"Rendering requester","Recalculate ?")) MyMenu |= REDRAW_MSG;
  3379.                                          }
  3380.  
  3381.                                          ResetMenuStrip (Ilbm->win,MAINMENU);
  3382.  
  3383.                                          ModifyIDCMP (Ilbm->win,IDCMP_STANDARD);
  3384.                                       }
  3385.  
  3386.                                       if (MyMenu & REDRAW_MSG)
  3387.                                       {
  3388.                                          if (ZMASK & MASK)
  3389.                                          {
  3390.                                             DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3391.  
  3392.                                             MASK ^= ZMASK;
  3393.                                          }
  3394.  
  3395.                                          SetMenuStop (Ilbm->win);
  3396.  
  3397.                                          PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3398.  
  3399.                                          ELAPSEDTIME = DrawFractal (Ilbm->win,(LONG) (Ilbm->win->LeftEdge),(LONG) (Ilbm->win->TopEdge),(LONG) (Ilbm->win->Width) - 1L,(LONG) (Ilbm->win->Height) - 1L);
  3400.  
  3401.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3402.  
  3403.                                          SetMenuStart (Ilbm->win);
  3404.  
  3405.                                          ShowTime (Ilbm->win,"Recalculate elapsed time:",ELAPSEDTIME);
  3406.  
  3407.                                          break;
  3408.                                       }
  3409.  
  3410.                                       if (MyMenu & UNDO_MSG)
  3411.                                       {
  3412.                                          if (ZMASK & MASK)
  3413.                                          {
  3414.                                             DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3415.  
  3416.                                             MASK ^= ZMASK;
  3417.                                          }
  3418.  
  3419.                                          RestoreCoords ();
  3420.  
  3421.                                          RealDist = fabs (RMAX-RMIN);
  3422.  
  3423.                                          ImagDist = fabs (IMAX-IMIN);
  3424.  
  3425.                                          Kre = RealDist / (double) (Ilbm->win->Width - 1);
  3426.  
  3427.                                          Kim = ImagDist / (double) (Ilbm->win->Height - 1);
  3428.  
  3429.                                          FracRatio = RealDist / ImagDist;
  3430.  
  3431.                                          PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3432.  
  3433.                                          SetMenuStop (Ilbm->win);
  3434.  
  3435.                                          SetRast (Ilbm->wrp,BLACK);
  3436.  
  3437.                                          ELAPSEDTIME = DrawFractal (Ilbm->win,(LONG) (Ilbm->win->LeftEdge),(LONG) (Ilbm->win->TopEdge),(LONG) (Ilbm->win->Width) - 1L,(LONG) (Ilbm->win->Height) - 1L);
  3438.  
  3439.                                          PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3440.  
  3441.                                          SetMenuStart (Ilbm->win);
  3442.  
  3443.                                          ShowTime (Ilbm->win,"Undo elapsed time:",ELAPSEDTIME);
  3444.  
  3445.                                          break;
  3446.                                       }
  3447.  
  3448.                                       if (MyMenu & DRAW_MSG)
  3449.                                       {
  3450.                                          if (ZMASK & MASK)
  3451.                                          {
  3452.                                             DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3453.  
  3454.                                             MASK ^= ZMASK;
  3455.                                          }
  3456.  
  3457.                                          if (NewCoords (Ilbm->win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4],ZOOMLINE [5]))
  3458.                                          {
  3459.                                             MYBITMAP = CopyBitMap (Ilbm->win,ZOOMLINE [6],ZOOMLINE [3],ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
  3460.  
  3461.                                             PasteWin (MYBITMAP,Ilbm->win,ZOOMLINE [4]-ZOOMLINE [6]+1,ZOOMLINE [5]-ZOOMLINE [3]+1);
  3462.  
  3463.                                             SetMenuStop (Ilbm->win);
  3464.  
  3465.                                             PutPointer (Ilbm->win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3466.  
  3467.                                             ELAPSEDTIME = DrawFractal (Ilbm->win,(LONG) (Ilbm->win->LeftEdge),(LONG) (Ilbm->win->TopEdge),(LONG) (Ilbm->win->Width) - 1L,(LONG) (Ilbm->win->Height) - 1L);
  3468.  
  3469.                                             PutPointer (Ilbm->win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3470.  
  3471.                                             SetMenuStart (Ilbm->win);
  3472.  
  3473.                                             ShowTime (Ilbm->win,"Zoom elapsed time:",ELAPSEDTIME);
  3474.                                          }
  3475.  
  3476.                                          break;
  3477.                                       }
  3478.  
  3479.                                       break;
  3480.  
  3481.              case       IDCMP_RAWKEY: if (MyCode == RAW_ESC) MyMenu = EXIT_MSG;
  3482.  
  3483.                                       break;
  3484.  
  3485.              case  IDCMP_CLOSEWINDOW: MyMenu = EXIT_MSG;
  3486.       }
  3487.  
  3488.     } while (! ((MyMenu & EXIT_MSG) || (MyMenu & NEWDISPLAY_MSG)));
  3489.  
  3490.     if (ZMASK & MASK)
  3491.     {
  3492.        DrawBorder (Ilbm->wrp,&MYBORDER,0,0);
  3493.  
  3494.        MASK ^= ZMASK;
  3495.     }
  3496.  
  3497.  return MyMenu;
  3498. }
  3499.  
  3500. struct BitMap *CopyBitMap (struct Window *Win,WORD Left,WORD Top,WORD Width,WORD Height)
  3501. {
  3502. struct BitMap *NewBM;
  3503.  
  3504.   NewBM = AllocBitMap (Width,Height,Win->RPort->BitMap->Depth,BMF_INTERLEAVED | BMF_CLEAR,NULL);
  3505.  
  3506.   if (NewBM)
  3507.   {
  3508.      if (ZMASK & MASK) DrawBorder (Win->RPort,&MYBORDER,0,0);
  3509.  
  3510.      if (TMASK & MASK) ShowTitle (Win->WScreen,FALSE);
  3511.  
  3512.      BltBitMap (Win->RPort->BitMap,Left,Top,NewBM,0,0,Width,Height,0xC0,0xFF,NULL);
  3513.  
  3514.      if (TMASK & MASK) ShowTitle (Win->WScreen,TRUE);
  3515.  
  3516.      if (ZMASK & MASK) DrawBorder (Win->RPort,&MYBORDER,0,0);
  3517.  
  3518.      MASK |= BMASK;
  3519.   }
  3520.  
  3521.   return NewBM;
  3522. }
  3523.  
  3524. BOOL PasteWin (struct BitMap *SrcBM,struct Window *DstWin,WORD SrcWidth,WORD SrcHeight)
  3525. {
  3526. BOOL Success = FALSE;
  3527.  
  3528. WORD DstWinWidth,DstWinHeight;
  3529.  
  3530. struct BitMap *TmpBM;
  3531.  
  3532.   if (SrcBM)
  3533.   {
  3534.      DstWinWidth = ((DstWin->Flags & WFLG_GIMMEZEROZERO) ? DstWin->GZZWidth : DstWin->Width);
  3535.  
  3536.      DstWinHeight = ((DstWin->Flags & WFLG_GIMMEZEROZERO) ? DstWin->GZZHeight : DstWin->Height);
  3537.  
  3538.      TmpBM = AllocBitMap (DstWinWidth,DstWinHeight,DstWin->RPort->BitMap->Depth,BMF_INTERLEAVED | BMF_CLEAR,NULL);
  3539.  
  3540.      if (TmpBM)
  3541.      {
  3542.         BSA.bsa_SrcWidth    = SrcWidth;
  3543.         BSA.bsa_SrcHeight   = SrcHeight;
  3544.         BSA.bsa_XSrcFactor  = SrcWidth;
  3545.         BSA.bsa_YSrcFactor  = SrcHeight;
  3546.         BSA.bsa_XDestFactor = DstWinWidth;
  3547.         BSA.bsa_YDestFactor = DstWinHeight;
  3548.         BSA.bsa_SrcBitMap   = SrcBM;
  3549.         BSA.bsa_DestBitMap  = TmpBM;
  3550.  
  3551.         BitMapScale (&BSA);
  3552.  
  3553.         BltBitMapRastPort (TmpBM,0,0,DstWin->RPort,0,0,DstWinWidth,DstWinHeight,0xC0);
  3554.  
  3555.         FreeBitMap (TmpBM);
  3556.  
  3557.         Success = TRUE;
  3558.      }
  3559.  
  3560.      FreeBitMap (SrcBM);
  3561.  
  3562.      MASK ^= BMASK;
  3563.   }
  3564.  
  3565.   return Success;
  3566. }
  3567.  
  3568. LONG WinDump (struct Window *Win)
  3569. {
  3570. struct IODRPReq *IODrp;
  3571. struct MsgPort  *PrinterPort;
  3572. struct ViewPort *Vp;
  3573.  
  3574. LONG Error = PDERR_BADDIMENSION;
  3575.  
  3576.   if (! Win) return Error;
  3577.  
  3578.   if (PrinterPort = CreatePort (0,0))
  3579.   {
  3580.      if (IODrp = (struct IODRPReq *) CreateExtIO (PrinterPort,sizeof (struct IODRPReq)))
  3581.      {
  3582.         if (! (Error = OpenDevice ("printer.device",0,(struct IORequest *) IODrp,0)))
  3583.         {
  3584.            Vp = ViewPortAddress (Win);
  3585.  
  3586.            IODrp->io_Command   = PRD_DUMPRPORT;
  3587.            IODrp->io_RastPort  = Win->RPort;
  3588.            IODrp->io_ColorMap  = Vp->ColorMap;
  3589.            IODrp->io_Modes     = (ULONG) Vp->Modes;
  3590.            IODrp->io_SrcX      = Win->LeftEdge;
  3591.            IODrp->io_SrcY      = Win->TopEdge;
  3592.            IODrp->io_SrcWidth  = Win->Width;
  3593.            IODrp->io_SrcHeight = Win->Height;
  3594.            IODrp->io_DestCols  = 0;
  3595.            IODrp->io_Special   = SPECIAL_FULLCOLS | SPECIAL_ASPECT;
  3596.  
  3597.            Error = DoIO ((struct IORequest *)IODrp);
  3598.  
  3599.            CloseDevice ((struct IORequest *)IODrp);
  3600.         }
  3601.  
  3602.         DeleteExtIO ((struct IORequest *)IODrp);
  3603.      }
  3604.  
  3605.      DeletePort (PrinterPort);
  3606.   }
  3607.  
  3608.   return Error;
  3609. }
  3610.  
  3611. ULONG Fail (UBYTE *ErrorString,ULONG ErrorLevel)
  3612. {
  3613.   DisplayAlert (RECOVERY_ALERT,ErrorString,30);
  3614.  
  3615.   RETURNVALUE = ErrorLevel;
  3616.  
  3617.   return RETURNVALUE;
  3618. }
  3619.  
  3620. LONG main (ULONG Argc,UBYTE **Argv)
  3621. {
  3622. UWORD ModeIDMaxPlanes;
  3623.  
  3624. UBYTE **ToolTypes;
  3625.  
  3626.   MYILBM.camg = DEF_MONITOR;
  3627.  
  3628.   MYILBM.Bmhd.w = DEF_WIDTH;
  3629.  
  3630.   MYILBM.Bmhd.h = DEF_HEIGHT;
  3631.  
  3632.   MYILBM.Bmhd.nPlanes = DEF_PLANES;
  3633.  
  3634.   if ((ToolTypes = ArgArrayInit (Argc,Argv)))
  3635.   {
  3636.      MYILBM.Bmhd.w       = ArgInt (ToolTypes,"SCREENWIDTH",DEF_WIDTH);
  3637.      MYILBM.Bmhd.h       = ArgInt (ToolTypes,"SCREENHEIGHT",DEF_HEIGHT);
  3638.      MYILBM.Bmhd.nPlanes = ArgInt (ToolTypes,"SCREENPLANES",DEF_PLANES);
  3639.  
  3640.      sscanf (ArgString (ToolTypes,"SCREENMODE",DEF_MONITORSTR),"%lx",&MYILBM.camg);
  3641.      sscanf (ArgString (ToolTypes,"REALMIN",INIT_DEF_RMINSTR),"%lf",&RMIN);
  3642.      sscanf (ArgString (ToolTypes,"REALMAX",INIT_DEF_RMAXSTR),"%lf",&RMAX);
  3643.      sscanf (ArgString (ToolTypes,"IMAGMIN",INIT_DEF_IMINSTR),"%lf",&IMIN);
  3644.      sscanf (ArgString (ToolTypes,"IMAGMAX",INIT_DEF_IMAXSTR),"%lf",&IMAX);
  3645.  
  3646.      ArgArrayDone ();
  3647.   }
  3648.  
  3649.   if (ModeNotAvailable (MYILBM.camg)) MYILBM.camg = ModeFallBack (MYILBM.camg,MYILBM.Bmhd.w,MYILBM.Bmhd.h,MYILBM.Bmhd.nPlanes);
  3650.  
  3651.   ModeIDMaxPlanes = GetMaxPlanes (MYILBM.camg);
  3652.  
  3653.   if (ModeIDMaxPlanes < 3)
  3654.   {
  3655.      Fail (OpenDisplayError,20L);
  3656.  
  3657.      exit (RETURNVALUE);
  3658.   }
  3659.  
  3660.   MYILBM.Bmhd.w       = MAX (MYILBM.Bmhd.w,DEF_WIDTH);
  3661.  
  3662.   MYILBM.Bmhd.h       = MAX (MYILBM.Bmhd.h,DEF_HEIGHT);
  3663.  
  3664.   MYILBM.Bmhd.nPlanes = MAX (MYILBM.Bmhd.nPlanes,MIN_DEPTH);
  3665.  
  3666.   if ((RMIN >= RMAX) || (IMIN >= IMAX))
  3667.   {
  3668.     DEF_RMIN = INIT_DEF_RMIN;
  3669.  
  3670.     DEF_RMAX = INIT_DEF_RMAX;
  3671.  
  3672.     DEF_IMIN = INIT_DEF_IMIN;
  3673.  
  3674.     DEF_IMAX = INIT_DEF_IMAX;
  3675.   }
  3676.  
  3677.   else
  3678.   {
  3679.     DEF_RMIN = RMIN;
  3680.  
  3681.     DEF_RMAX = RMAX;
  3682.  
  3683.     DEF_IMIN = IMIN;
  3684.  
  3685.     DEF_IMAX = IMAX;
  3686.   }
  3687.  
  3688.   SaveCoords ();
  3689.  
  3690.   MYILBM.ParseInfo.propchks = IlbmProps;
  3691.  
  3692.   MYILBM.ParseInfo.collectchks = IlbmCollects;
  3693.  
  3694.   MYILBM.ParseInfo.stopchks = IlbmStops;
  3695.  
  3696.   MYILBM.Bmhd.pageWidth  = 0;
  3697.  
  3698.   MYILBM.Bmhd.pageHeight = 0;
  3699.  
  3700.   MYILBM.stype = CUSTOMSCREEN | SCREENQUIET;
  3701.  
  3702.   MYILBM.TBState = TMASK & MASK;
  3703.  
  3704.   MYILBM.ucliptype = OSCAN_TEXT;
  3705.  
  3706.   MYILBM.EHB = TRUE;
  3707.  
  3708.   MYILBM.Autoscroll = TRUE;
  3709.  
  3710.   MYILBM.IFFPFlags = NULL;
  3711.  
  3712.   FUNCTION = Integer;
  3713.  
  3714.   PALETTE = COLORS_32_AGA;
  3715.  
  3716.   H_LINE = HLine_S;
  3717.  
  3718.   V_LINE = VLine_S;
  3719.  
  3720.   if (MYILBM.Bmhd.nPlanes > ModeIDMaxPlanes) MYILBM.Bmhd.nPlanes = ModeIDMaxPlanes;
  3721.  
  3722.   if (! CheckGFX ()) PALETTE = COLORS_32_ECS;
  3723.  
  3724.   if (MAINMENU = CreateMenus (ProgMenu,TAG_END))
  3725.   {
  3726.      if (MYILBM.Bmhd.nPlanes < 6)
  3727.      {
  3728.         MAX_ITERATIONS = 63;
  3729.  
  3730.         ItemAddress (MAINMENU,FULLMENUNUM (1,2,4))->Flags ^= CHECKED;
  3731.  
  3732.         ItemAddress (MAINMENU,FULLMENUNUM (1,2,0))->Flags |= CHECKED;
  3733.      }
  3734.  
  3735.      if (CheckEHB (MYILBM.camg))
  3736.      {
  3737.         H_LINE = HLine_S_EHB;
  3738.  
  3739.         V_LINE = VLine_S_EHB;
  3740.      }
  3741.  
  3742.      if (CheckFPU (SysBase->AttnFlags))
  3743.      {
  3744.         FUNCTION = Real;
  3745.  
  3746.         ItemAddress (MAINMENU,FULLMENUNUM (1,5,0))->Flags ^= CHECKED;
  3747.  
  3748.         ItemAddress (MAINMENU,FULLMENUNUM (1,5,1))->Flags |= CHECKED;
  3749.      }
  3750.  
  3751.      if (COLOR_PENS = MakeDisplay (&MYILBM))
  3752.      {
  3753.         COLOR_PENS -= 4L;
  3754.  
  3755.         MANDChunk.LeftEdge = MYILBM.win->LeftEdge;
  3756.  
  3757.         MANDChunk.TopEdge = MYILBM.win->TopEdge;
  3758.  
  3759.         MANDChunk.Width = MYILBM.win->Width;
  3760.  
  3761.         MANDChunk.Height = MYILBM.win->Height;
  3762.  
  3763.         MANDChunk.RMin = RMIN;
  3764.  
  3765.         MANDChunk.RMax = RMAX;
  3766.  
  3767.         MANDChunk.IMin = IMIN;
  3768.  
  3769.         MANDChunk.IMax = IMAX;
  3770.  
  3771.         MANDChunk.Iterations = MAX_ITERATIONS + 1L;
  3772.  
  3773.         MANDChunk.Special = NULL;
  3774.  
  3775.         SPECIAL_CHUNK.ch_Data = &MANDChunk;
  3776.  
  3777.         PutPointer (MYILBM.win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3778.  
  3779.         ELAPSEDTIME = DrawFractal (MYILBM.win,(LONG) (MYILBM.win->LeftEdge),(LONG) (MYILBM.win->TopEdge),(LONG) (MYILBM.win->Width) - 1L,(LONG) (MYILBM.win->Height) - 1L);
  3780.  
  3781.         PutPointer (MYILBM.win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3782.  
  3783.         SetMenuStart (MYILBM.win);
  3784.  
  3785.         ShowTime (MYILBM.win,"Rendering elapsed time:",ELAPSEDTIME);
  3786.  
  3787.         ModifyIDCMP (MYILBM.win,NULL);
  3788.  
  3789.         ClearMenuStrip (MYILBM.win);
  3790.  
  3791.         About (MYILBM.win);
  3792.  
  3793.         ResetMenuStrip (MYILBM.win,MAINMENU);
  3794.  
  3795.         ModifyIDCMP (MYILBM.win,IDCMP_STANDARD);
  3796.  
  3797.         do
  3798.         {
  3799.           while (HandleEvents (&MYILBM) & NEWDISPLAY_MSG)
  3800.           {
  3801.                 if (SMRequest (&MYILBM))
  3802.                 {
  3803.                    MYBITMAP = CopyBitMap (MYILBM.win,MYILBM.win->LeftEdge,MYILBM.win->TopEdge,MYILBM.win->Width,MYILBM.win->Height);
  3804.  
  3805.                    CloseDisplay (&MYILBM,VINFO);
  3806.  
  3807.                    MYILBM.Bmhd.pageWidth  = 0;
  3808.  
  3809.                    MYILBM.Bmhd.pageHeight = 0;
  3810.  
  3811.                    COLOR_PENS = MakeDisplay (&MYILBM);
  3812.  
  3813.                    if (COLOR_PENS)
  3814.                    {
  3815.                       COLOR_PENS -= 4L;
  3816.  
  3817.                       PasteWin (MYBITMAP,MYILBM.win,GetBitMapAttr (MYBITMAP,BMA_WIDTH),GetBitMapAttr (MYBITMAP,BMA_HEIGHT));
  3818.  
  3819.                       if (CheckEHB (MYILBM.camg))
  3820.                       {
  3821.                          if (SPREAD == FALSE)
  3822.                          {
  3823.                             H_LINE = HLine_R_EHB;
  3824.  
  3825.                             V_LINE = VLine_R_EHB;
  3826.                          }
  3827.  
  3828.                          else
  3829.                          {
  3830.                             H_LINE = HLine_S_EHB;
  3831.  
  3832.                             V_LINE = VLine_S_EHB;
  3833.                          }
  3834.                       }
  3835.  
  3836.                       else
  3837.                       {
  3838.                          if (SPREAD == FALSE)
  3839.                          {
  3840.                             H_LINE = HLine_R;
  3841.  
  3842.                             V_LINE = VLine_R;
  3843.                          }
  3844.  
  3845.                          else
  3846.                          {
  3847.                             H_LINE = HLine_S;
  3848.  
  3849.                             V_LINE = VLine_S;
  3850.                          }
  3851.                       }
  3852.  
  3853.                       if (Choice (MYILBM.win,"Rendering requester","Recalculate ?"))
  3854.                       {
  3855.                          SetMenuStop (MYILBM.win);
  3856.  
  3857.                          PutPointer (MYILBM.win,ZZZPointer,ZZZPW,ZZZPH,ZZZPXO,ZZZPYO,1);
  3858.  
  3859.                          ELAPSEDTIME = DrawFractal (MYILBM.win,(LONG) (MYILBM.win->LeftEdge),(LONG) (MYILBM.win->TopEdge),(LONG) (MYILBM.win->Width) - 1L,(LONG) (MYILBM.win->Height) - 1L);
  3860.  
  3861.                          PutPointer (MYILBM.win,ZoomPointer,ZPW,ZPH,ZPXO,ZPYO,2);
  3862.  
  3863.                          SetMenuStart (MYILBM.win);
  3864.  
  3865.                          ShowTime (MYILBM.win,"Rendering elapsed time:",ELAPSEDTIME);
  3866.                       }
  3867.                   }
  3868.  
  3869.                   else
  3870.                   {
  3871.                          Fail (MakeDisplayError,20L);
  3872.  
  3873.                          break;
  3874.                   }
  3875.                }
  3876.           }
  3877.  
  3878.           if (RETURNVALUE >= 20L) break;
  3879.  
  3880.         } while (! Choice (MYILBM.win,"Exit requester","Are you sure ?"));
  3881.  
  3882.         if (BMASK & MASK) FreeBitMap (MYBITMAP);
  3883.      }
  3884.  
  3885.      else Fail (MakeDisplayError,20L);
  3886.  
  3887.      CloseDisplay (&MYILBM,VINFO);
  3888.  
  3889.      FreeMenus (MAINMENU);
  3890.   }
  3891.  
  3892.   else Fail (MenuError,20L);
  3893.  
  3894.   exit (RETURNVALUE);
  3895. }
  3896.